C++: undetected undeclared identifier in template
Peter Bienstman
Peter.Bienstman@rug.ac.be
Fri Nov 12 05:05:00 GMT 1999
Hi,
In the following code, 'undefined_f_uncatched' is not detected as an
undeclared identifier because 'unused' is not used. In the same code
rewritten without templates, this programming error is not overlooked.
template<class T> struct A
{
void used() {undefined_f_catched();}
void unused() {undefined_f_uncatched();}
};
int main()
{
A<int> a;
a.used();
return 0;
}
wsbob:/users/wsbob_4/ocs/pbienst/camfr2$gcc -v
Reading specs from
/users/wsbob_4/ocs/pbienst/bin/gnu/lib/gcc-lib/sparc-sun-solaris
2.6/2.96/specs
gcc version 2.96 19991110 (experimental)
wsbob:/users/wsbob_4/ocs/pbienst/camfr2$g++ warning.cpp -Wall
warning.cpp: In method `void A<T>::used () [with T = int]':
warning.cpp:10: instantiated from here
warning.cpp:3: `undefined_f_catched' undeclared (first use this function)
warning.cpp:3: (Each undeclared identifier is reported only once
warning.cpp:3: for each function it appears in.)
... but no word on `undefined_f_uncatched'
Peter
-------------------------------------
Peter Bienstman
Department of Information Technology
INTEC/IMEC - University of Gent
St.-Pietersnieuwstraat 41
B-9000 Gent - Belgium
E-mail: Peter.Bienstman@rug.ac.be
Tel: +32 9 264 3445
Fax: +32 9 264 3593
-------------------------------------
More information about the Gcc-bugs
mailing list