#2179 unexpected C compiler error, when compiling C source file, generated by cito (Ć --> C lang translator)

open
nobody
None
other
5
2014-10-29
2013-06-02
valen
No

Hi,

I'm trying to compile a simple C source file,
which was generated by cito (Ć Programming Language) translator (Ć --> C).
But i got an error:
the SDCC C compiler think (for some reason), what an initializer is not const, but it is const.
Check the C source file object.c (attached).
Original ci source file is attached too object.ci.cpp (just in case).

sdcc -v
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.3.1 #8699 (May 31 2013) (Linux)

translate to C

cito -l c -o ./object.c ./object.ci.cpp

compile

sdcc -mz80 ./object.c
./object.c:29: error 2: Initializer element is not constant
./object.c:31: error 2: Initializer element is not constant
./object.c:61: warning 85: in function GameObj_Move unreferenced function argument : 'self'
./object.c:86: warning 85: in function MovingGameObj_Draw unreferenced function argument : 'self'

So, in the error lines, the are two pointers to function (which is const), used as initializers.
But compiler, for some reason, see this pointers as non-const.

1 Attachments

Discussion

  • valen
    valen
    2013-06-02

    object.h

     
    Attachments
  • valen
    valen
    2013-06-02

    object.ci.cpp

     
    Attachments
  • I attached a small compileable example by extracting the relevant bits from the source files given by the bug reporter.
    This is a bug, since the initializer element is a constant expression (see section 6.6 of the C11 standard, in particular "pointer casts may be used in the creation of an address constant").

    Philipp

     
    Attachments
    • valen
      valen
      2014-10-29

      Thanks, Philipp!

      (I had to do this, when i started this bug.)

       
      Last edit: valen 2014-10-29