Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save andrey-malets/ef3306e8f695496634db5ea8ede4b1f4 to your computer and use it in GitHub Desktop.

Select an option

Save andrey-malets/ef3306e8f695496634db5ea8ede4b1f4 to your computer and use it in GitHub Desktop.
malets@mac:~$ cat 2.cc
constexpr int f() {
int x[] = {0};
return x[1];
}
int main(void) {
return f();
}
malets@mac:~$ clang++ -std=c++14 2.cc
2.cc:3:10: warning: array index 1 is past the end of the array (which contains 1 element) [-Warray-bounds]
return x[1];
^ ~
2.cc:2:3: note: array 'x' declared here
int x[] = {0};
^
1 warning generated.
malets@mac:~$ ./a.out
malets@mac:~$ echo $?
240
malets@mac:~$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment