public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59081] New: GCC should forbid using a private member datatype in template class
@ 2013-11-11 20:55 romain.geissler at gmail dot com
  2013-11-11 23:42 ` [Bug c++/59081] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: romain.geissler at gmail dot com @ 2013-11-11 20:55 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/59081] GCC should forbid using a private member datatype in template class
  2013-11-11 20:55 [Bug c++/59081] New: GCC should forbid using a private member datatype in template class romain.geissler at gmail dot com
@ 2013-11-11 23:42 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-11 23:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Please check whether this is a duplicate of any of the "Depends on" bugs for PR
59002


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/59081] GCC should forbid using a private member datatype in template class
  2013-11-11 20:55 [Bug c++/59081] New: GCC should forbid using a private member datatype in template class romain.geissler at gmail dot com
  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
  2 siblings, 0 replies; 4+ messages in thread
From: romain.geissler at gmail dot com @ 2013-11-11 23:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Romain Geissler <romain.geissler at gmail dot com> ---
It looks similar to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41437 but in my
case I used a second class, not a function.

This issue is exactly like the one reported in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47346 by Jason Merrill  2013-03-27
13:28:24 UTC, but not like the one you reported first.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/59081] GCC should forbid using a private member datatype in template class
  2013-11-11 20:55 [Bug c++/59081] New: GCC should forbid using a private member datatype in template class romain.geissler at gmail dot com
  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
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-12  1:07 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
dup then

*** This bug has been marked as a duplicate of bug 47346 ***


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-12  1:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-11 20:55 [Bug c++/59081] New: GCC should forbid using a private member datatype in template class romain.geissler at gmail dot com
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

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).