https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100296
Bug ID: 100296 Summary: [10.x regression] offsetof with non-constant-expression offset no longer accepted in C++ mode Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: davem at devkitpro dot org Target Milestone: --- The following code compiles fine as C but produces " error: 'idx' is not a constant expression" with gcc 11.1.0 #include <stdint.h> #include <stddef.h> struct foo { uint8_t things[12]; }; uintptr_t getThing(const unsigned idx) { return offsetof(struct foo, things[idx]); } The code compiles fine with gcc 6.x through 10.x gcc 5.x says "error: 'idx' cannot appear in a constant-expression"