This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ bug in 3.3.2: function pointer args and templates
- From: Greg Lindahl <lindahl at pathscale dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 21 Jul 2004 18:57:15 -0700
- Subject: g++ bug in 3.3.2: function pointer args and templates
The following program compiles OK in gcc 3.2.2 and 3.4.0 but gives a syntax
error in gcc 3.3.2.
OK with: gcc 3.2.2-5 as distributed in Red Hat 9 i386
Not OK with: gcc 3.3.2-1 as distributed in Fedora Core 1 x86_64
OK with: gcc 3.4.0-1 as distributed in Fedora Core 2 i386
I'm not a C++ language laywer, but supposedly Sun's language lawyer
has blessed this example.
g++ -c test4.cc
test4.cc: In member function `AttributeT<char*, int>*
AttrManager::NewUserAttribute(const char*, const VcbSearchSet&)':
test4.cc:40: error: `NewAttribute<char*, int>' undeclared (first use this
function)
test4.cc:40: error: (Each undeclared identifier is reported only once for each
function it appears in.)
--------- test4.cc -------------------------------------------------------------
#define NULL 0x00000000
class AttrManager;
static AttrManager* attr_manager;
template <class T, class Obj>
class AttributeT {
public:
int x;
};
class VcbSearchSet {
public:
VcbSearchSet(void*);
};
class AttrManager {
public:
AttrManager();
~AttrManager();
template <class T, class Obj>
AttributeT<T, Obj>* NewAttribute(const char* name, int vm,
const char* help, const VcbSearchSet& vcbs,
T (*default_value_function) (),
int (*check_obj_and_value_function) (Obj*,T)
)
{
return NULL;
}
AttributeT<char*, int>* AttrManager::NewUserAttribute(const char* name,
const VcbSearchSet& vcbs)
{
int avm_user = 1;
return attr_manager->
AttrManager::NewAttribute<char*, int>(name, avm_user,
"user defined", vcbs, (char*(*)())NULL, (int(*)(int*,char*))NULL);
}
};