public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3496: template parm shadow reporting when it is not
@ 2001-06-30  5:16 khlebnikov
  0 siblings, 0 replies; 2+ messages in thread
From: khlebnikov @ 2001-06-30  5:16 UTC (permalink / raw)
  To: gcc-gnats

>Number:         3496
>Category:       c++
>Synopsis:       template parm shadow reporting when it is not
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 30 05:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     g++
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
Kernel 2.4.5, glibc 2.1, i686
>Description:
I want to access a template class ttype parameter outside the class.
Code example:

//////// begin /////////

template <class T> class C {
 
public:
    typedef T T;
    T v;
};
 
//void main () {
//
//      typedef C <int> CC;
//      CC::T i;
//}                           

////////////// end ////////////////////

gcc reports:
$g++ -c error.cpp
error.cpp:4: declaration of `typedef T C<T>::T'
error.cpp:1:  shadows template parm `class T'
error.cpp:4: declaration of `typedef T C<T>::T'
error.cpp:1: changes meaning of `T' from `class T'   

So, type T is "shadowed" by type T. I think, this is not an error
in code, but a compiler bug.
MS Visual C++ compiles this OK.

Detailed out:
$g++ -v -save-temps -c error.cpp
>How-To-Repeat:
g++ -c error.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="error.ii"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="error.ii"

IyAxICJlcnJvci5jcHAiCnRlbXBsYXRlIDxjbGFzcyBUPiBjbGFzcyBDIHsKCnB1YmxpYzoKCXR5
cGVkZWYgVCBUOwogICAgVCB2Owp9OwoKIAogCiAKIAogCg==


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

* Re: c++/3496: template parm shadow reporting when it is not
@ 2001-08-12  3:38 gdr
  0 siblings, 0 replies; 2+ messages in thread
From: gdr @ 2001-08-12  3:38 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, gdr, khlebnikov, nobody

Synopsis: template parm shadow reporting when it is not

Responsible-Changed-From-To: unassigned->gdr
Responsible-Changed-By: gdr
Responsible-Changed-When: Sun Aug 12 03:38:47 2001
Responsible-Changed-Why:
    See below.
State-Changed-From-To: open->closed
State-Changed-By: gdr
State-Changed-When: Sun Aug 12 03:38:47 2001
State-Changed-Why:
    This is not a compiler bug.  Your program is ill-formed and 
    VC++ is at error.  See 14.6.1/4:
       A template-parameter shall not be redeclared within its scope (including nested scopes).
    
    -- Gaby

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3496&database=gcc


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

end of thread, other threads:[~2001-08-12  3:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-30  5:16 c++/3496: template parm shadow reporting when it is not khlebnikov
2001-08-12  3:38 gdr

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