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]

Mysterious namespace and typedef interactions



I'm getting seemingly bizarre interactions between namespaces and typedefs using the CVS source (20010219 on Solaris
2.6, 20010222 on Solaris 2.8).  I'm not sure if it's a bug or I (as is often the case) am failing to understand some
subtlety of the language.

I've boiled down the problem to the following file whittled from preprocessed source, consisting of lines from
Solaris system header files.  

// fails with "c++ -c bull.cpp"
namespace _C_legacy {
	typedef struct __FILE __FILE;
	typedef int ssize_t;

	struct __FILE
	{
		ssize_t _cnt;
	};
}
// gives error "bull.cpp:7: syntax error before `;' token"                                                  
      
The following two variants will compile.

// no forward reference typedef
namespace _C_legacy {
	typedef int ssize_t;

	struct __FILE
	{
		ssize_t _cnt;
	};
}

// namespace qualification
namespace _C_legacy {
	typedef struct __FILE __FILE;
	typedef int ssize_t;

	struct __FILE
	{
		_C_legacy::ssize_t _cnt;
	};
}


It seems to me that if this is not a bug, a lot of existing code is going to break.  The error does not occur with
gcc 2.95.2 or the Solaris WS6 C++ compiler.



Stephen M. Webb


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