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++/53794] New: [c++11, accepts invalid] dangling reference accepted in nested structures with initializer lists


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53794

             Bug #: 53794
           Summary: [c++11, accepts invalid] dangling reference accepted
                    in nested structures with initializer lists
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dirkmoermans@gmail.com


The code below is currently accepted without warning by gcc-4.6.3 and
gcc-4.7.0.

===
struct A
{
   int& i;
};

struct B
{
   A a;
};

int main()
{
   B b1{}; // BUG: accepts invalid
   // B b2; // rejected
};
===

I think it should be rejected, since uninitialized references are not allowed
by the language.


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