possibly a bug in g++
Hello there.
Seems like I've discovered a bug in g++-3.0 (or, at least, g++-2.95).
The following code is rejected by g++-3.0:
====================================
template <class TFunc>
void tpl_func (const TFunc& func)
{
return;
}
static bool compare_ints (int a, int b)
{
return (a < b);
}
void trigger_the_bug ()
{
tpl_func (compare_ints);
}
====================================
$g++-2.95 -c error.cpp
(no messages, successfull compilation)
$g++-3.0 -c error.cpp
error.cpp: In function `void trigger_the_bug()':
error.cpp:14: no matching function for call to `tpl_func(bool (&)(int, int))'
If replace "tpl_func (compare_ints)" by "tpl_func (&compare_ints)", compilation
succeeds. AFAIK, function name is a name of pointer to it as well, so g++-3.0
has a bug. I use g++ version 3.0.2. This example also compiles unsuccessfully on
another (not mine) machine with SuSE Linux and g++ 3.0.2 release built from
sources, so this bug(?) is not debian-specific.
Here are versions of my g++ - related packages:
||/ Name Version Description
+++-==============-==============-============================================
ii gcc 2.95.4-6 The GNU C compiler.
ii gcc-2.95 2.95.4-0.01081 The GNU C compiler.
ii gcc-3.0 3.0.2-2 The GNU C compiler.
ii gcc-3.0-base 3.0.2-2 The GNU Compiler Collection (base package).
ii gcc-3.0-doc 3.0.2-2 Documentation for the GNU compilers (gcc, go
ii g++ 2.95.4-6 The GNU C++ compiler.
ii g++-2.95 2.95.4-0.01081 The GNU C++ compiler.
ii g++-3.0 3.0.2-2 The GNU C++ compiler.
Please answer somebody wether it is a bug and wether I should submit it to
GNATS.
Regards,
Alexei.
PS.
Every g++ problem I face with is template-related. Ugh!
Reply to: