[Bug c++/107039] New: GCC not diagnosing UB in constant expression
jlame646 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Sep 26 08:44:16 GMT 2022
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.
More information about the Gcc-bugs
mailing list