Topic: Sun C++ 4.0.1 bug with scoping of typedefs?


Author: schmidt@tango.cs.wustl.edu (Douglas C. Schmidt)
Date: 27 Jan 1995 18:16:35 -0600
Raw View
Hi,

 The latest version of Sun C++ 4.0.1 gives a compile time error
for the following:

----------------------------------------
class CORBA
{
public:
  typedef unsigned int boolean;
};

typedef enum boolean {B_TRUE, B_FALSE} boolean_t;
----------------------------------------

x.C", line 7: Error: Multiple declaration for boolean.
1 Error(s) detected.

----------------------------------------

If the order is reversed, the compiler is happy.

This code comes from a CORBA application that is including
<sys/types.h>.

It seems that the Sun C++ 4.0.1 compiler has a bug, but I'm curious to
know whether the working draft standard scopes the typedef in class
CORBA such that the type is hidden from the global scope.

Thanks for any info,

 Doug
--
Dr. Douglas C. Schmidt    (schmidt@cs.wustl.edu)
Department of Computer Science, Washington University
St. Louis, MO 63130. Work #: (314) 935-7538; FAX #: (314) 935-7302
http://www.cs.wustl.edu/~schmidt/




Author: ball@Eng.Sun.COM (Mike Ball)
Date: 30 Jan 1995 17:25:52 GMT
Raw View
In article s85@tango.cs.wustl.edu, schmidt@tango.cs.wustl.edu (Douglas C. Schmidt) writes:
> Hi,
>
>  The latest version of Sun C++ 4.0.1 gives a compile time error
> for the following:
>
> ----------------------------------------
> class CORBA
> {
> public:
>   typedef unsigned int boolean;
> };
>
> typedef enum boolean {B_TRUE, B_FALSE} boolean_t;
> ----------------------------------------
>
> x.C", line 7: Error: Multiple declaration for boolean.
> 1 Error(s) detected.

This is indeed a bug that seems to have crept into the most recent release.

If you are interested, it's a consequence of a hack that attempts to allow
anachronistic references to class scope types from the global scope.  It's
supposed to be disabled if someone declares a global scope type with the
same name, but it got messed up for enums.

I've been wanting to get rid of that hack for a long time anyway.....

Attempting to allow old code to continue to compile despite changes in the
language is always challenging, but customers seem to want it.  (deep sigh)
(Whether the sigh is directed at the changes or the customers is left as an
exercise for the reader.)

Mike Ball
SunSoft Developer Products

Hint:  I understand the reasons for both the changes and the customers desires...