https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109991
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Status|UNCONFIRMED |NEW Component|sanitizer |c++ Last reconfirmed| |2023-05-26 Ever confirmed|0 |1 Blocks| |55004 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- That is because with constexpr, the code should have been rejected ... Take this C++20 GCC accepts it (incorrectly) but clang rejects it: ``` using T = int; struct Wrap { T const& v; constexpr Wrap(T const& in) : v{in} {} }; struct BadWrapUse final { T i{}; consteval BadWrapUse() { Wrap w{T{}}; // temporary T's lifetime ends after this expression i = w.v; // This should lead to stack-use-after-scope. } }; int main() { BadWrapUse c; } ``` Note there might be a dup of it somewhere. Basically in your original example, GCC is doing constexpr evulation but that is not valid for constant expression evulation ... Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55004 [Bug 55004] [meta-bug] constexpr issues