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++/16777] New: C++ parse error in 3.3, OK in 3.2 and 3.4


Reading specs from /usr/lib/gcc-lib/x86_64-redhat-linux/3.3.2/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
--host=x86_64-redhat-linux
Thread model: posix
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)

This is OK in gcc 3.2, broken in gcc 3.3 (e.g. 3.3.2 from redhat), ok in gcc 3.4.0
 
g++ -c test4a.cc
test4a.cc: In member function `AttributeT<char*, int>*
   AttrManager::NewUserAttribute(const char*, const VcbSearchSet&)':
test4a.cc:40: error: `NewAttribute<char*, int>' undeclared (first use this
   function)
test4a.cc:40: error: (Each undeclared identifier is reported only once for each
   function it appears in.)
-----test4a.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, NULL, NULL);
  }
 
};
 
----------------------------------------------------------------------
funky attempts to cast the NULL don't help: (and shouldn't be needed)
----------------------------------------------------------------------
This shows a workaround, remove the AttrManager:: in the call
----------------------------------------------------------------------
g++ -c test4b.cc
 
-----test4b.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->
      NewAttribute<char*, int>(name, avm_user,
      "user defined", vcbs, (char*(*)())NULL, (int(*)(int*,char*))NULL);
  }
 
};
 
----------------------------------------------------------------------

-- 
           Summary: C++ parse error in 3.3, OK in 3.2 and 3.4
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lindahl at pathscale dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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