This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c++/14364] New: Function should depend on template


Using g++ 3.4: 
 
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.0/specs 
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-shared --enable-threads=posix 
--disable-checking --with-system-zlib --enable-__cxa_atexit 
--disable-libunwind-exceptions --enable-languages=c,c++,objc,java,f77 
--host=x86_64-redhat-linux 
Thread model: posix 
gcc version 3.4.0 20040221 (Red Hat Linux 3.4.0-0.5) 
 
and with Fedora's g++-ssa: 
Reading specs from /lib64/ssa/gcc/x86_64-redhat-linux-gnu/3.5-tree-ssa/specs 
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --libdir=/lib64/ssa --libexecdir=/lib64/ssa 
--host=x86_64-redhat-linux-gnu --enable-shared --enable-threads=posix 
--disable-checking --enable-languages=c,c++,java,objc,f95 --with-system-zlib 
--enable-__cxa_atexit --disable-multilib 
Thread model: posix 
gcc version 3.5-tree-ssa 20040120 (Fedora Core Rawhide 3.5ssa-110) 
 
The following program no longer compiles, with the error: 
gcctemplates.cpp: In member function `int Foo<K>::Hash() const': 
gcctemplates.cpp:6: error: `::CalcHash' has not been declared 
 
If you remove the '::' From ::CalcHash() on line 6, then the program 
will compile just fine. GCC 3.3 and below, HP and Sun's c++ compiler all 
compile both versions without complaint. 
 
(Bug 13157 sounds very similar, perhaps they are the same?) 
 
 
#include <stdio.h> 
 
template< class K > class Foo { 
public: 
   Foo( const K& k ) : store( k ) {} 
   int Hash() const { return ::CalcHash( store ); } 
 
private: 
   K store; 
}; 
 
class Bar { 
public: 
   Bar( int x ) : val( x ) {} 
   int val; 
}; 
 
static inline int 
CalcHash( const Bar& b ) { return b.val; } 
 
int main( int, char ** ) { 
   Foo< Bar > testing( 10 ); 
   printf( "%d\n", testing.Hash() ); 
   return 0; 
}

-- 
           Summary: Function should depend on template
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ben at zeus dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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