public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37350]  New: Specialized template base class name not accepted
@ 2008-09-03 14:07 ian at airs dot com
  2008-09-03 14:51 ` [Bug c++/37350] " rguenth at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ian at airs dot com @ 2008-09-03 14:07 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1327 bytes --]

C++98 [temp.local] says "Within the scope of a class template specialization or
partial specialization, when the name of the template is neither qualified nor
followed by <, it is equivalent to the name of the template followed by the
template-arguments enclosed in <>."  That does not work when a template
specialization is used as a base class.  In that case g++ does not accept the
unqualified base class name as a type.

This test case:

template <class T>
struct base {};

struct derived : base<int> {
  typedef base b;
  base* p;
};

gives these errors:

foo.cc:5: error: invalid use of template-name ‘base’ without an argument list
foo.cc:6: error: ISO C++ forbids declaration of ‘base’ with no type
foo.cc:6: error: expected ‘;’ before ‘*’ token

I believe this is an incorrect rejection of valid C++ code.  At least, I can't
find anything in the C++ standard which says that this code is invalid.


-- 
           Summary: Specialized template base class name not accepted
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


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


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

* [Bug c++/37350] Specialized template base class name not accepted
  2008-09-03 14:07 [Bug c++/37350] New: Specialized template base class name not accepted ian at airs dot com
@ 2008-09-03 14:51 ` rguenth at gcc dot gnu dot org
  2008-09-03 14:53 ` rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-03 14:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-09-03 14:50 -------
I don't read from the sentence that this applies to base class names, it
says "the name of the template" only.


-- 


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


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

* [Bug c++/37350] Specialized template base class name not accepted
  2008-09-03 14:07 [Bug c++/37350] New: Specialized template base class name not accepted ian at airs dot com
  2008-09-03 14:51 ` [Bug c++/37350] " rguenth at gcc dot gnu dot org
@ 2008-09-03 14:53 ` rguenth at gcc dot gnu dot org
  2008-09-04  3:39 ` ian at airs dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-09-03 14:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-09-03 14:51 -------
EDG rejects it with

t.C(5): error: argument list for class template "base" is missing
        typedef base b;
                ^

but accepts it if you use derived instead of base (like gcc does).


-- 


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


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

* [Bug c++/37350] Specialized template base class name not accepted
  2008-09-03 14:07 [Bug c++/37350] New: Specialized template base class name not accepted ian at airs dot com
  2008-09-03 14:51 ` [Bug c++/37350] " rguenth at gcc dot gnu dot org
  2008-09-03 14:53 ` rguenth at gcc dot gnu dot org
@ 2008-09-04  3:39 ` ian at airs dot com
  2008-09-04  4:00 ` pinskia at gcc dot gnu dot org
  2009-12-23 23:31 ` redi at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: ian at airs dot com @ 2008-09-04  3:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ian at airs dot com  2008-09-04 03:38 -------
Here is further argument from a programmer here.  Any language lawyers want to
comment?

14.6.1 Locally declared names [temp.local]
1. Like normal (non-template) classes, class templates have an
injected-class-name (clause 9). The injected-class-name can be used with or
without a template-argument-list. When it is used without a
template-argument-list, it is equivalent to the injected-class-name followed by
the template-parameters of the class template enclosed in <>. When it is used
with a template-argument-list, it refers to the specified class template
specialization, which could be the current specialization or another
specialization.

It makes this code valid:
template <class T>
struct base {
  typedef base b;
};

And now according to this:
9 Classes [class]
2  A class-name is inserted into the scope in which it is declared immediately
after the class-name is seen. The class-name is also inserted into the scope of
the class itself; this is known as the injected-class-name. For purposes of
access checking, the injected-class-name is treated as if it were a public
member name. A class-specifier is commonly referred to as a class definition. A
class is considered defined after the closing brace of its class-specifier has
been seen even though its member functions are in general not yet defined.

injected-class-name is public, therefore it is accessible in derived class. It
makes the example valid.


-- 


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


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

* [Bug c++/37350] Specialized template base class name not accepted
  2008-09-03 14:07 [Bug c++/37350] New: Specialized template base class name not accepted ian at airs dot com
                   ` (2 preceding siblings ...)
  2008-09-04  3:39 ` ian at airs dot com
@ 2008-09-04  4:00 ` pinskia at gcc dot gnu dot org
  2009-12-23 23:31 ` redi at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-04  4:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2008-09-04 03:59 -------
Looks like this is a dup of bug 9937.


-- 


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


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

* [Bug c++/37350] Specialized template base class name not accepted
  2008-09-03 14:07 [Bug c++/37350] New: Specialized template base class name not accepted ian at airs dot com
                   ` (3 preceding siblings ...)
  2008-09-04  4:00 ` pinskia at gcc dot gnu dot org
@ 2009-12-23 23:31 ` redi at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu dot org @ 2009-12-23 23:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from redi at gcc dot gnu dot org  2009-12-23 23:31 -------


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


-- 

redi at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2009-12-23 23:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-03 14:07 [Bug c++/37350] New: Specialized template base class name not accepted ian at airs dot com
2008-09-03 14:51 ` [Bug c++/37350] " rguenth at gcc dot gnu dot org
2008-09-03 14:53 ` rguenth at gcc dot gnu dot org
2008-09-04  3:39 ` ian at airs dot com
2008-09-04  4:00 ` pinskia at gcc dot gnu dot org
2009-12-23 23:31 ` redi at gcc dot gnu dot 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).