public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "romain.geissler at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59081] New: GCC should forbid using a private member datatype in template class Date: Mon, 11 Nov 2013 20:55:00 -0000 [thread overview] Message-ID: <bug-59081-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59081 Bug ID: 59081 Summary: GCC should forbid using a private member datatype in template class Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: romain.geissler at gmail dot com Hi, GCC should emit an error in the C class when referencing A::B in the following code (as clang does). class A{ private: struct B{} _b; }; template <typename T> class C{ public: A::B* _b; }; C<void> c; Tested with gcc 4.8.2 and also the latest 4.9.0 trunk: Using built-in specs. COLLECT_GCC=/remote/intdeliv/seidelde/local/gcc/bin/../latest/bin/g++ COLLECT_LTO_WRAPPER=/remote/intdeliv/seidelde/local/gcc/4.8.2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-sources/configure --prefix /remote/intdeliv/seidelde/local/gcc/4.8.2 --with-gmp=/remote/intdeliv/seidelde/local/gmp/5.1.3 --with-mpfr=/remote/intdeliv/seidelde/local/mpfr/3.1.2 --with-mpc=/remote/intdeliv/seidelde/local/mpc/1.0.1 --enable-lto --disable-multilib --enable-languages=c,c++ Thread model: posix gcc version 4.8.2 (GCC) With clang I got the expected behavior: rgeissler@ncegcolnx273:/tmp> ~seidelde/local/clang/bin/clang++ -c test.cpp test.cpp:8:12: error: 'B' is a private member of 'A' A::B* _b; ^ test.cpp:3:16: note: declared private here struct B{} _b; ^ 1 error generated. Cheers, Romain
next reply other threads:[~2013-11-11 20:55 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-11-11 20:55 romain.geissler at gmail dot com [this message] 2013-11-11 23:42 ` [Bug c++/59081] " redi at gcc dot gnu.org 2013-11-11 23:56 ` romain.geissler at gmail dot com 2013-11-12 1:07 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-59081-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).