Re: [PATCH] c++: Allow constexpr references to non-static vars [PR100976]

2021-07-17 Thread Jason Merrill via Gcc-patches
On 7/16/21 1:44 PM, Marek Polacek wrote: On Fri, Jul 16, 2021 at 12:53:05PM -0400, Jason Merrill wrote: On 7/15/21 5:14 PM, Marek Polacek wrote: The combination of DR 2481 and DR 2126 should allow us to do void f() { constexpr const int &r = 42; static_assert(r == 42);

Re: [PATCH] c++: Allow constexpr references to non-static vars [PR100976]

2021-07-16 Thread Marek Polacek via Gcc-patches
On Fri, Jul 16, 2021 at 12:53:05PM -0400, Jason Merrill wrote: > On 7/15/21 5:14 PM, Marek Polacek wrote: > > The combination of DR 2481 and DR 2126 should allow us to do > > > >void f() > >{ > > constexpr const int &r = 42; > > static_assert(r == 42); > >} > > > > because [

Re: [PATCH] c++: Allow constexpr references to non-static vars [PR100976]

2021-07-16 Thread Jason Merrill via Gcc-patches
On 7/15/21 5:14 PM, Marek Polacek wrote: The combination of DR 2481 and DR 2126 should allow us to do void f() { constexpr const int &r = 42; static_assert(r == 42); } because [expr.const]/4.7 now says that "a temporary object of non-volatile const-qualified literal type whos

[PATCH] c++: Allow constexpr references to non-static vars [PR100976]

2021-07-15 Thread Marek Polacek via Gcc-patches
The combination of DR 2481 and DR 2126 should allow us to do void f() { constexpr const int &r = 42; static_assert(r == 42); } because [expr.const]/4.7 now says that "a temporary object of non-volatile const-qualified literal type whose lifetime is extended to that of a variable tha