Created
October 12, 2012 10:20
-
-
Save anonymous/3878566 to your computer and use it in GitHub Desktop.
stdin
This file contains 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
void *av_x_if_null(const void *x, const void *y) | |
{ | |
return (void *) (x ? x : y); | |
} | |
int foo[1]; | |
#define av_x_if_null_warn(x,y) \ | |
( \ | |
foo[sizeof(*x)!=sizeof(*y)] = 42, \ | |
av_x_if_null(x, y) \ | |
) | |
int main(void) | |
{ | |
int *a = 0; | |
char *b = 0; | |
int *i = av_x_if_null_warn(a, a); // fine | |
short *c = av_x_if_null_warn(a, b); | |
// foo.c: In function ‘main’: | |
// foo.c:18:13: warning: array subscript is above array bounds [-Warray-bounds] | |
return c ? 1 : 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment