[Bug c++/100976] [C++23] Make constexpr reference temp constexpr
jason at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jun 8 20:51:35 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100976
--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Or rather,
int main()
{
constexpr const int &r = 42;
static_assert(r == 42); // { dg-bogus "" }
}
[expr.const]/4.7 says that "a temporary object of non-volatile const-qualified
literal type whose lifetime is extended to that
of a variable that is usable in constant expressions" is usable in a constant
expression.
More information about the Gcc-bugs
mailing list