https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107039
Bug ID: 107039 Summary: GCC not diagnosing UB in constant expression Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jlame646 at gmail dot com Target Milestone: --- GCC doesn't give diagnostic for the following program while clang and msvc do. Demo: https://godbolt.org/z/o3K57fjeE ``` struct S { int a, b; }; constexpr void fn( S &s ) { (&s.b)[-1] = 123; } constexpr auto test = ([]{ S s; fn(s); }(), 0); ``` There should be a diagnostic for the above code.