From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9549 invoked by alias); 1 Jul 2011 03:21:29 -0000 Received: (qmail 9541 invoked by uid 22791); 1 Jul 2011 03:21:28 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_BJ,TW_CX,TW_DC,TW_GC,TW_GX X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Jul 2011 03:21:14 +0000 From: "b.r.longbons at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/49604] New: forward-declared enum in class scope is private in context of constexpr X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: b.r.longbons at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Fri, 01 Jul 2011 03:21:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg00014.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49604 Summary: forward-declared enum in class scope is private in context of constexpr Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: b.r.longbons@gmail.com Created attachment 24652 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24652 Minimal testcase If an enum is forward-declared as a public member of a class (but not a struct), and the values are defined afterward, then the enum values cannot be be used in the context of a constexpr: enum-broken.cpp:9:26: error: 'Foo::impl_t Foo::X' is private enum-broken.cpp:11:27: error: within this context (see attachment) Workaround: Use 'struct' instead of 'class'. What works: It works fine if 'struct' is used instead of 'class'. It works fine without the constexpr. It works fine if the enum values are defined in the declaration. It works find if the nested type is a struct with a static member. Versions: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.6.0/work/gcc-4.6.0/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.0/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --disable-nls --with-system-zlib --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --enable-cld --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.6.0/python --enable-checking=release --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.6.0 p1.2, pie-0.4.5' Thread model: posix gcc version 4.6.0 (Gentoo 4.6.0 p1.2, pie-0.4.5) Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.1-1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-multiarch --with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib/x86_64-linux-gnu --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.6.1 (Debian 4.6.1-1)