https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83215
Bug ID: 83215 Summary: C++: struct with char-array assumed to alias with everything Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: dominik.infuehr at gmail dot com Target Milestone: --- TBAA seems to be more conservative for C++ in the following example since GCC 7: struct mytest { float a; #ifdef WITH_BUFFER char buf[256]; #endif }; int foo(mytest *m, int *i) { int tmp = *i; // first load m->a = 10.0f; return tmp + *i; // second load since GCC 7 } Since GCC 7 this code generates two loads with -DWITH_BUFFER, without buf in the struct there is just one load. buf isn't touched at all in this function. This only affects C++-code, not the C-frontend. TYPE_TYPLESS_STORAGE is set for this struct, aggregates with this flag set are assumed to alias with everything in gcc/alias.c(get_alias_set). Seems to be introduced with revision 246866 (https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=246866).