This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/68782] New: [6 regression] bad reference member formed with constexpr


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

            Bug ID: 68782
           Summary: [6 regression] bad reference member formed with
                    constexpr
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lucdanton at free dot fr
  Target Milestone: ---

Using 6.0.0 20151208 the last two asserts fire, whereas they don't with GCC
5.2.1 (as expected). The issue seems constexpr related as not marking
from_value and from_aggr constexpr makes it go away.

Compiled using:

    g++-trunk -std=c++11 main.cpp

-std=c++14 and -std=c++1z result in the same behaviour.

----------------------------------------
#include <cassert>

struct holder { int& value; };

constexpr holder from_value(int& value)
{ return { value }; }

struct aggr { int i; };

constexpr holder from_aggr(aggr& a)
{ return from_value(a.i); }

int main()
{
    aggr a { 42 };

    // these don't fire
    assert( &from_value(a.i).value != nullptr );
    assert( &a.i == &from_value(a.i).value );

    // those do
    assert( &from_aggr(a).value != nullptr );
    assert( &a.i == &from_aggr(a).value );
}
----------------------------------------

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]