This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52369] New: Const-qualified non-class base member and defaulted default constructor
- From: "ai.azuma at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 24 Feb 2012 11:22:38 +0000
- Subject: [Bug c++/52369] New: Const-qualified non-class base member and defaulted default constructor
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: ai.azuma@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 .