Re: Fixes for 0.5.3 on OSF1

I've done a significant amount of investigation on the problem of enum
representation, including talking to one of our compiler guys.  His
answer was (minorly edited for brevity):

> First, it should be pretty easy to write a test to see if an
> enum is an int or a signed int.  The following should do:
> enum {A = 0xffffffff};
> int main() {
>     if (A  < 0) 
>         printf("enum A is a signed type\n");
>     else
>         printf("enum A is an unsigned type\n");
> }
> I ran the program using Compaq C, VAX C, Sun's C compiler,
> HP's C compiler, and gcc.  All but gcc output:
>     enum A is a signed type
> gcc outputs:
>     enum A is an unsigned type
> Note that if the -pedantic option is given to gcc, it will emit 
> a diagnostic:
>     warning: ANSI C restricts enumerator values to range of `int'
> So...gcc must look at the value of the enumerated constant and
> if it does not fit in a signed int, but would fit in an unsigned
> int, gcc will give the enum constant a type of unsigned int.
> Note that gcc goes further...if the enum constant value is larger
> than an unsigned int, gcc will make it a long int.  For example:
> enum {A = 0xfffffffff};
> int main() {
>     printf("size of A is %d\n",sizeof(A));
> }
> will output:
>     size of A is 8
> So...if 0xffffffff is being used as an enum value, there may
> be a difference in behavior when converting from gcc to Compaq
> C (or any other C compiler I tried).

I think it will be hard to tell if this will have an impact on
networked ORBit between architectures without simply testing.  I
suspect that it will function properly, however I could be mistaken.
Unfortunately, changing the ORBit enum for CORBA_tk_recursive probably
isn't possible at this point.

If there is somebody with ORBit compiled on gcc and ORBit compiled on
Compaq C who could to a test between them, I would appreciate hearing
the results.  I don't presently have anything here that is
gcc-compiled, nor do I have code to test.

If it works, I would ignore the warning.  If it doesn't, then we'll
explore how to patch the code so that it does.


Aron Griffis                  
Tru64 UNIX Platform & Kernel
Compaq Computer Corporation, ZKO3-3/T30

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]