https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119754
Bug ID: 119754
Summary: std::uninitialized_value_construct does not begin
lifetime of trivial types
Product: gcc
Version: unknown
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
#include <algorithm>
#include <memory>
consteval bool f(int n)
{
int* p = std::allocator<int>().allocate(n);
std::uninitialized_value_construct(p, p+n);
std::allocator<int>().deallocate(p, n);
return true;
}
static_assert(f(10));
With -std=c++26 GCC accepts this, but Clang doesn't:
ef.cc:12:15: error: static assertion expression is not an integral constant
expression
12 | static_assert(f(10));
| ^~~~~
/home/jwakely/gcc/15/lib/gcc/x86_64-pc-linux-gnu/15.0.1/../../../../include/c++/15.0.1/bits/stl_algobase.h:925:11:
note: assignment to object outside its lifetime is not allowed in a constant
expression
925 | *__first = __val;
| ~~~~~~~~~^~~~~~~