Last active
November 18, 2022 15:22
-
-
Save jerstlouis/4a3c54e507a1f546b8d0830f642ff959 to your computer and use it in GitHub Desktop.
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
// Compile with GCC 12.2.0 with -O2: | |
// warning: ‘strcpy’ offset 0 is out of the bounds [0, 0] [-Warray-bounds] | |
// no warning without -O2 | |
extern char * strcpy(char * , const char * ); | |
struct Inst { int bla; }; | |
struct Class { int offset; }; | |
static struct Class * classFoo; // No problem without static here | |
struct Foo | |
{ | |
unsigned int a; // no problem if commented out | |
char bar[1024]; | |
}; | |
void setFoo(struct Inst * this, const char * value) | |
{ | |
struct Foo * ptr = (struct Foo *)(this ? (((char *)this) + classFoo->offset) : 0); | |
strcpy(ptr->bar, value); | |
} | |
int main() { return 0; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment