[omniORB] const unsigned long 0xffffffff

Sai-Lai Lo S.Lo@orl.co.uk
06 Apr 1998 19:52:16 +0100


Thanks for the bug report.

The lexical parser processes all integer constants as signed. The following
patch fixed the bug but causes the compiler to accept the following
construct as well:

const unsigned long x = -1;

I'm not sure this is what we want. Something to look into.

In the meantime, here is the patch to get the compiler to accept 0xffffffff.

------------------------- cut ----------------------
*** src/tool/omniidl2/ast/ast_expression.cc	Wed Feb 25 20:38:41 1998
--- srcnew/tool/omniidl2/ast/ast_expression.cc	Mon Apr  6 19:42:02 1998
***************
*** 495,502 ****
        ev->et = AST_Expression::EV_ulong;
        return ev;
      case AST_Expression::EV_long:
-       if (ev->u.lval < 0)
- 	return NULL;
        ev->u.ulval = (unsigned long) ev->u.lval;
        ev->et = AST_Expression::EV_ulong;
        return ev;
--- 495,500 ----

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


Melih Ercan xe44 9777 <ercanm@access.bel.alcatel.be> writes:

> 
> When I define the following in IDL:
> 
> const unsigned long myConst=0xffffffff;
> 
> I got the following error msg from the IDL compiler:
> 
> omniidl2: "tank.idl", line 1: coercion failure -1 to unsigned long
> omniidl2: tank.idl: found 1 error
> 
> It is obvious that the constant 0xffffffff is seen as signed (i.e. -1).
> So I will get an error
> message for all constants greater than 0x80000000. Is there a way to say
> that 0xffffffff
> is unsigned?
> 

-- 
Dr. Sai-Lai Lo                          |       Research Scientist
                                        |
E-mail:         S.Lo@orl.co.uk          |       Olivetti & Oracle Research Lab
                                        |       24a Trumpington Street
Tel:            +44 223 343000          |       Cambridge CB2 1QA
Fax:            +44 223 313542          |       ENGLAND