public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52620] New: using cannot import types in (non direct) base classes
@ 2012-03-19 16:11 akim.demaille at gmail dot com
  2012-03-19 16:12 ` [Bug c++/52620] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: akim.demaille at gmail dot com @ 2012-03-19 16:11 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52620
           Summary: using cannot import types in (non direct) base classes
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: akim.demaille@gmail.com


Created attachment 26919
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26919
Test case

I might be missing something, sorry if this is just noise.  It looks
very much like http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51971 ,
but instead of "using" from the immediate base class, it fails when
"using" from a grand-child.  I checked the standard, and according to
_my_ reading it should work, yet this case is not presented as an example.

Please note that neither "using" in "bot" work.  I have left both of
them, but of course one should suffice.  It is interesting to note that
both are accepted (g++ does not report the "using" declarations as
errors - except for the duplication), yet it seems impossible to use
the imported name.

Thanks!


$ g++-mp-4.7 -std=c++0x -Wall foo.cc
foo.cc:18:3: error: 'type' does not name a type
foo.cc: In instantiation of 'struct bot<bool>':
foo.cc:28:13:   required from here
foo.cc:17:26: error: redeclaration of 'using med<bool>::type'
foo.cc:16:14: note: previous declaration 'using top::type'
foo.cc: In function 'int main()':
foo.cc:26:19: warning: unused variable 'vm' [-Wunused-variable]
foo.cc:30:19: warning: unused variable 'vb' [-Wunused-variable]

$ g++-mp-4.7 --version
g++-mp-4.7 (GCC) 4.7.0 20120225 (experimental)
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



$ g++-4.2  -Wall foo.cc
foo.cc:18: error: ‘type’ does not name a type
foo.cc: In function ‘int main()’:
foo.cc:26: warning: unused variable ‘vm’
foo.cc:30: warning: unused variable ‘vb’

$ g++-4.2  --version
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



FWIW, clang 3.1 accepts both versions (using from top or from med<T>).


PS/  It is extremely confusing to be submit possible "duplicates"
that are not even C++ :(


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

* [Bug c++/52620] using cannot import types in (non direct) base classes
  2012-03-19 16:11 [Bug c++/52620] New: using cannot import types in (non direct) base classes akim.demaille at gmail dot com
@ 2012-03-19 16:12 ` redi at gcc dot gnu.org
  2012-03-19 16:31 ` akim.demaille at gmail dot com
  2012-03-19 16:35 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-19 16:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-03-19 16:10:08 UTC ---
template <typename T>
struct bot: med<T>
{
  using top::type;

This is not valid, med<T> is a dependent base class so name lookup never looks
in it, so top is not known to be a base class.

If you remove that line G++ accepts the code.


> PS/  It is extremely confusing to be submit possible "duplicates"
> that are not even C++ :(

I assume you mean the list of possible dups when filling in the form?
Your "C++" bug might actually be a middle-end bug, or a preprocessor bug, or
something else, so it makes sense to look for dups across the whole database.


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

* [Bug c++/52620] using cannot import types in (non direct) base classes
  2012-03-19 16:11 [Bug c++/52620] New: using cannot import types in (non direct) base classes akim.demaille at gmail dot com
  2012-03-19 16:12 ` [Bug c++/52620] " redi at gcc dot gnu.org
@ 2012-03-19 16:31 ` akim.demaille at gmail dot com
  2012-03-19 16:35 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: akim.demaille at gmail dot com @ 2012-03-19 16:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Akim Demaille <akim.demaille at gmail dot com> 2012-03-19 16:16:37 UTC ---
(I pasted the wrong bug report, I meant
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21484)

(In reply to comment #1)
> template <typename T>
> struct bot: med<T>
> {
>   using top::type;
> 
> This is not valid, med<T> is a dependent base class so name lookup never looks
> in it, so top is not known to be a base class.

Ah, thanks for the clarification!

> If you remove that line G++ accepts the code.

Ah, somehow I broke my tests.  4.6.3 does not accept it (and is the compiler
I am actually using), but you are right that 4.7.0 is fine with it.

> > PS/  It is extremely confusing to be submit[ted] possible "duplicates"
> > that are not even C++ :(
> 
> I assume you mean the list of possible dups when filling in the form?
> Your "C++" bug might actually be a middle-end bug, or a preprocessor bug, or
> something else, so it makes sense to look for dups across the whole database.

Candidates were about Java :)  But I understand, thanks.


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

* [Bug c++/52620] using cannot import types in (non direct) base classes
  2012-03-19 16:11 [Bug c++/52620] New: using cannot import types in (non direct) base classes akim.demaille at gmail dot com
  2012-03-19 16:12 ` [Bug c++/52620] " redi at gcc dot gnu.org
  2012-03-19 16:31 ` akim.demaille at gmail dot com
@ 2012-03-19 16:35 ` redi at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2012-03-19 16:35 UTC (permalink / raw)
  To: gcc-bugs

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

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> 2012-03-19 16:31:04 UTC ---
(In reply to comment #2)
> (I pasted the wrong bug report, I meant
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21484)

That's a dup of PR 14258 so should be fixed for 4.7, and I think this is the
same issue.


> (In reply to comment #1)
> > template <typename T>
> > struct bot: med<T>
> > {
> >   using top::type;
> > 
> > This is not valid, med<T> is a dependent base class so name lookup never looks
> > in it, so top is not known to be a base class.
> 
> Ah, thanks for the clarification!

I believe it's a bug in clang if it accepts it.


> > If you remove that line G++ accepts the code.
> 
> Ah, somehow I broke my tests.  4.6.3 does not accept it (and is the compiler
> I am actually using), but you are right that 4.7.0 is fine with it.

Yes, the 'using' code was significantly improved for 4.7, see the release notes
at http://gcc.gnu.org/gcc-4.7/changes.html#cxx

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


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

end of thread, other threads:[~2012-03-19 16:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-19 16:11 [Bug c++/52620] New: using cannot import types in (non direct) base classes akim.demaille at gmail dot com
2012-03-19 16:12 ` [Bug c++/52620] " redi at gcc dot gnu.org
2012-03-19 16:31 ` akim.demaille at gmail dot com
2012-03-19 16:35 ` 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).