Created
June 14, 2017 22:02
-
-
Save brimston3/5f3e423cf1af3665ff2dc1ae539e6f6d to your computer and use it in GitHub Desktop.
unexpected success with restrict keyword punning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I expect this to generate errors on mismatched prototypes but apparently it does not. I should probably figure out why. | |
// gcc -std=c1x -Wstrict-aliasing -Wall -Wno-unused-but-set-variable restrict_punning.c | |
// clang -std=c1x -Wstrict-aliasing -Wall restrict_punning.c | |
void f1(char * restrict a, char * b) | |
{ | |
return; | |
} | |
void f2(char * a, char * b) | |
{ | |
return; | |
} | |
int main() { | |
void (*fp1)(char * restrict a, char * b); | |
void (*fp2)(char * a, char * b); | |
fp1 = f1; // match | |
fp1 = f2; // fc missing restrict | |
fp2 = f1; // fc extra restrict | |
fp2 = f2; // match | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment