Created
October 5, 2012 18:50
-
-
Save willglynn/3841654 to your computer and use it in GitHub Desktop.
Negative array indices
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
#include <stdio.h> | |
int main() { | |
struct { | |
int scalar; | |
int array[5]; | |
} some_struct; | |
some_struct.scalar = 5; | |
printf("%i\n", some_struct.array[-1]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
clang
compiles this -- at any optimization level -- to: