https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105407
Bug ID: 105407
Summary: std::construct_at during constant evaluation does not
zero-initialize
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
This example program:
```
#include <memory>
#include <iostream>
struct A {
int x = x;
};
constexpr int foo() {
A a{1};
std::construct_at<A>(&a);
return a.x;
}
int main() {
constexpr int v = foo();
std::cout << v << foo();
}
```
shall print "00" (as Clang and MSVC do), because before "x=x" std::construct_at
must zero-initialize (a), see https://eel.is/c++draft/dcl.init#general-9.1.2
GCC prints "10" (demo: https://gcc.godbolt.org/z/eoEr5KMjM) meaning that it
behaves correctly in run-time, but not during constant evaluation.