[Bug c++/29039] New: implicitly defined constructor for class with reference member

amylaar at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Sep 12 18:52:00 GMT 2006


The following ill-formed code is accepted:

typedef struct
{
  int &r;
} S;

S
f ()
{
  return S ();
}


12.1 ; 5 states that if there is no user-declared constructor for a class, a
default constructor is implicitly declared. 12.1 ; 7 states that such a
constructor is implicitly defined when it is used to create an object of its
class type, and that it performs the same set of initializations that would be
performed by a user-written default constructor with an empty
mem-initializer-list. 12.6.2 ; 4 says that if an entity not named in a
mem-initializer-id is of reference type, the program is ill-formed.


-- 
           Summary: implicitly defined constructor for class with reference
                    member
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amylaar at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list