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

             Bug #: 52369
           Summary: Const-qualified non-class base member and defaulted
                    default constructor
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: ai.az...@gmail.com


Created attachment 26740
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26740
Output of -v option and preprocessed file

The following ill-formed code is wrongly accepted by GCC 4.7.0 20120218
(experimental).

////////////////////
class B
{
private:
  int const v_;
};

class D
  : public B
{};

int main()
{
  D d;
}
////////////////////

B's default constructor is implicitly-declared and has no ctor-initializer. So,
B::v_ is not designated by any mem-initializer-id and subject to
default-initialization. However, default-initialization of a const-qualified
non-class type is ill-formed. Therefore, the use of B's constructor is
ill-formed (and it should be defined as deleted in -std=c++11 mode), and the
use of D's is also ill-formed.

N.B. A similar (but a bit different) problem seems to have been resolved in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29043 .

Reply via email to