Bug 2944

Summary: octet constants broken
Product: TAO Reporter: Lothar Werzinger <lothar>
Component: IDL CompilerAssignee: DOC Center Support List (internal) <tao-support>
Status: REOPENED ---    
Severity: major    
Priority: P3    
Version: 1.5.8   
Hardware: All   
OS: All   

Description Lothar Werzinger 2007-05-25 12:59:10 CDT
ACE VERSION: 5.5.8

    HOST MACHINE and OPERATING SYSTEM:
Linux zaphod 2.6.15-28-amd64-generic #1 SMP PREEMPT Tue Mar 13 20:51:52 UTC 2007 x86_64 GNU/Linux

    TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
    COMPILER NAME AND VERSION (AND PATCHLEVEL):
gcc (GCC) 4.1.2

    THE $ACE_ROOT/ace/config.h FILE [if you use a link to a platform-
    specific file, simply state which one]:
#define ACE_HAS_XML_SVC_CONF
// workaround for bug in gcc 4.0.x
#define ACE_LACKS_PRAGMA_ONCE
#include "ace/config-linux.h"

    THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE [if you
    use a link to a platform-specific file, simply state which one
    (unless this isn't used in this case, e.g., with Microsoft Visual
    C++)]: 
# configure ACE/TAO for our use

templates=automatic
debug=1
optimize=1
exceptions=1
threads=1
inline=1
rtti=1
versioned_so=1
ssl=1
#no_hidden_visibility=1


# Disable the RCSID for release/non-debug builds.
CPPFLAGS += -DACE_USE_RCSID=0

CC = /opt2/linux/ix86/x86_64-pc-linux-gnu/bin/gcc
CXX = /opt2/linux/ix86/x86_64-pc-linux-gnu/bin/g++
CFLAGS += -m64 -I/opt2/linux/x86_64/include
CCFLAGS += -m64 -I/opt2/linux/x86_64/include
LDFLAGS += -m64 -I/opt2/linux/x86_64/include -L/opt2/linux/x86_64/lib

TAO_IDL_PREPROCESSOR = /opt2/linux/ix86/x86_64-pc-linux-gnu/bin/gcc

include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU


    CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
    (used by MPC when you generate your own makefiles):

    AREA/CLASS/EXAMPLE AFFECTED:
[What example failed?  What module failed to compile?]

    DOES THE PROBLEM AFFECT:
        OTHER (please specify)
IDL compilation

    SYNOPSIS:
IDL compiler chokes on valid IDL

    DESCRIPTION:
When I compile the attached IDL file I get the following errors:

tao_idl: "test.idl", line 7: illegal infix operator in expression
tao_idl: "test.idl", line 7: coercion failure  <<  to octet
tao_idl: "test.idl", line 8: illegal infix operator in expression
tao_idl: "test.idl", line 8: coercion failure  <<  to octet
tao_idl: "test.idl", line 9: illegal infix operator in expression
tao_idl: "test.idl", line 9: coercion failure  <<  to octet
tao_idl: "test.idl", line 11: illegal infix operator in expression
tao_idl: "test.idl", line 11: coercion failure  + 2 to octet
tao_idl: "test.idl", line 12: illegal infix operator in expression
tao_idl: "test.idl", line 12: coercion failure  + 4 to octet
tao_idl: "test.idl", line 13: illegal infix operator in expression
tao_idl: "test.idl", line 13: coercion failure  + 8 to octet
processing test.idl
tao_idl: test.idl: found 12 errors


If I read chapter 3.10 Constant Declaration in 
http://www.omg.org/docs/formal/02-06-39.pdf I get the impression that my IDL 
should be valid IDL, as it reads:

An octet constant can be defined using an integer literal or an integer 
constant expression, for example:
     const octet O1 = 0x1;
     const long L = 3;
     const octet O2 = 5 + L;
Values for an octet constant outside the range 0 - 255 shall cause a 
compile-time error.


as e.g (1 << 3) is within the range 0 - 255 and it is valid to initialize an 
octet with "an integer constant expression" I think my IDL is valid.
and the examples c_o11 - c_o13 resemble the example from the OMG document, but 
they fail, too.

    REPEAT BY:
Recompile IDL file with IDL compiler

    SAMPLE FIX/WORKAROUND:
unknown


Here's the IDL

module test
{
  const unsigned long c_l1 = (1 << 1);
  const unsigned long c_l2 = (1 << 2);
  const unsigned long c_l3 = (1 << 3);

  const octet c_o1 = (1 << 1);
  const octet c_o2 = (1 << 2);
  const octet c_o3 = (1 << 3);

  const octet c_o11 = 10 + c_l1;
  const octet c_o12 = 10 + c_l2;
  const octet c_o13 = 10 + c_l3;
};
Comment 1 Jeff Parsons 2007-05-25 14:14:34 CDT
Fri May 25 18:49:12 UTC 2007  Jeff Parsons <j.parsons@vanderbilt.edu>

        * TAO_IDL/ast/ast_expression.cpp:
        
          Fixed a bug in parsing of octet constants where the rhs
          has an infix operator. Thanks to Lother Werzinger
          <lothar at tradescape dot biz> for reporting the
          problem. This fix closes [BUGID:2944].
          
        * tests/IDL_Test/constants.idl:
        
          Added some of items in the example IDL submitted by
          Lothar to our test suite of problem IDL declarations.

Comment 2 Abdul Sowayan 2007-06-03 18:15:42 CDT
Reopening this ticket per the following ChangLong:

Sun Jun  3 19:57:23 UTC 2007  Jeff Parsons <j.parsons@vanderbilt.edu>

        * tests/IDL_Test/constants.idl:
        
          Commented out a recently-added
          
          Fri May 25 18:49:12 UTC 2007  Jeff Parsons <j.parsons@vanderbilt.edu>
          
          addition to this file - an octet constant with a left-shift
          operator in the rhs literal. My fix to AST_Expression in
          the above checkin didn't work for big-endian systems. Possible
          approaches to a complete fix all involve protracted design
          changes in expression handling, so the problem IDL is commented out
          for now.