This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/3496: template parm shadow reporting when it is not



>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==


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]