https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119754

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #0)
> #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;
>       |         ~~~~~~~~~^~~~~~~

Fixed on trunk by r16-2154-g82d2d12da93b5a

Reply via email to