public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/36019]  New: template parameter does not hide class name
@ 2008-04-22 21:30 deba at inf dot elte dot hu
  2008-12-28  6:29 ` [Bug c++/36019] [4.2/4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: deba at inf dot elte dot hu @ 2008-04-22 21:30 UTC (permalink / raw)
  To: gcc-bugs

If a member template is defined with same template parameter name as the class
name, then this parameter does not hide the class name.
The following code explains the problem:

#include <iostream>

struct B {
  static const int x = 1;
};

struct A {
  static const int x = 0;
  template <typename A>
  static void f() {
    std::cerr << A::x << std::endl;
  }
};

int main() {
  A::f<B>();
  return 0;
}

The result of the program is 0, while it should be 1.

Compilation:
> g++ -v -save-temps ns_bug.cc
Using built-in specs.                                                           
Target: i486-linux-gnu                                                          
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2
--program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --disable-libmudflap --enable-targets=all
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu                                                         
Thread model: posix                                                             
gcc version 4.2.3 (Debian 4.2.3-3)                                              
 /usr/lib/gcc/i486-linux-gnu/4.2.3/cc1plus -E -quiet -v -D_GNU_SOURCE ns_bug.cc
-mtune=generic -fpch-preprocess -o ns_bug.ii                                    
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"              
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../i486-linux-gnu/include"          
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.2
 /usr/include/c++/4.2/i486-linux-gnu
 /usr/include/c++/4.2/backward
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.2.3/include
 /usr/include
End of search list.
 /usr/lib/gcc/i486-linux-gnu/4.2.3/cc1plus -fpreprocessed ns_bug.ii -quiet
-dumpbase ns_bug.cc -mtune=generic -auxbase ns_bug -version -o ns_bug.s
GNU C++ version 4.2.3 (Debian 4.2.3-3) (i486-linux-gnu)
        compiled by GNU C version 4.2.3 (Debian 4.2.3-3).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: f63294e1c8ecc1bf2473a5bae1642fbe
 as -V -Qy -o ns_bug.o ns_bug.s
^[[6~GNU assembler version 2.18.0 (i486-linux-gnu) using BFD version (GNU
Binutils for Debian) 2.18.0.20080103
 /usr/lib/gcc/i486-linux-gnu/4.2.3/collect2 --eh-frame-hdr -m elf_i386
--hash-style=both -dynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/crt1.o
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/crti.o
/usr/lib/gcc/i486-linux-gnu/4.2.3/crtbegin.o
-L/usr/lib/gcc/i486-linux-gnu/4.2.3 -L/usr/lib/gcc/i486-linux-gnu/4.2.3
-L/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib -L/lib/../lib
-L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.2.3/../../.. ns_bug.o
-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/i486-linux-gnu/4.2.3/crtend.o
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/crtn.o


-- 
           Summary: template parameter does not hide class name
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: deba at inf dot elte dot hu
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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


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

end of thread, other threads:[~2009-03-03 22:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-22 21:30 [Bug c++/36019] New: template parameter does not hide class name deba at inf dot elte dot hu
2008-12-28  6:29 ` [Bug c++/36019] [4.2/4.3/4.4 Regression] " pinskia at gcc dot gnu dot org
2008-12-29 21:35 ` rguenth at gcc dot gnu dot org
2009-01-07  1:11 ` dodji at gcc dot gnu dot org
2009-01-08 23:03 ` dodji at gcc dot gnu dot org
2009-01-09 19:11 ` dodji at gcc dot gnu dot org
2009-01-12 22:41 ` dodji at gcc dot gnu dot org
2009-01-12 22:44 ` dodji at gcc dot gnu dot org
2009-01-12 22:48 ` dodji at gcc dot gnu dot org
2009-01-12 22:50 ` dodji at gcc dot gnu dot org
2009-01-12 23:01 ` jakub at gcc dot gnu dot org
2009-01-13 16:50 ` dodji at redhat dot com
2009-03-03 22:01 ` jason at gcc dot gnu dot org
2009-03-03 22:01 ` jason 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).