Bug 117651 - Read of an uninitialized subobject not detected in constant expression
Summary: Read of an uninitialized subobject not detected in constant expression
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 14.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2024-11-18 11:50 UTC by Fedor Chelnokov
Modified: 2024-11-23 13:54 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 12.1.0, 13.3.0, 15.0
Last reconfirmed: 2024-11-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fedor Chelnokov 2024-11-18 11:50:02 UTC
This program
```
struct B { 
    int v;
};

constexpr B g() { B b; return b; }
static_assert( g().v == 0 );
```
must fail because v-subobject is not initialized, and it does so in Clang and MSVC. Unfortunately, GCC accepts the program just fine. Online demo: https://gcc.godbolt.org/z/5Kbqxjrej
Comment 1 Drea Pinski 2024-11-18 18:55:31 UTC
Confirmed.