Menu

#2872 error 2: Initializer element is not a constant expression (regression)

closed-fixed
None
other
5
2019-03-10
2019-02-10
No

Since a while constructs such as

int i = (2 ? 3 : 4) + (2 ? 3 : 4);

const int j = (2 ? 3 : 4) + (2 ? 3 : 4);

are not accepted by SDCC anymore. I tried MCS51 and STM8 targets and both seem affected, although not in exactly the same way.

With older SDCC this was not an issue. Below some details on the versions. The attached a file contains the same information.

SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ez80_z80/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.8.5 #10914 (MINGW32) published under GNU General Public License (GPL)

MCS51
sdcc -S -mmcs51 test-1.c
test-1.c:3: error 2: Initializer element is not a constant expression

MCS51 large
sdcc -S -mmcs51 --model-large test-1.c
test-1.c:1: error 2: Initializer element is not a constant expression
test-1.c:3: error 2: Initializer element is not a constant expression
test-1.c:4: error 2: Initializer element is not a constant expression

STM8
sdcc -S -mstm8 test-1.c
test-1.c:1: error 2: Initializer element is not a constant expression
test-1.c:3: error 2: Initializer element is not a constant expression
test-1.c:4: error 2: Initializer element is not a constant expression

STM8 large
sdcc -S -mstm8 --model-large test-1.c
test-1.c:1: error 2: Initializer element is not a constant expression
test-1.c:3: error 2: Initializer element is not a constant expression
test-1.c:4: error 2: Initializer element is not a constant expression

SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.5.0 #9253 (Jun 20 2015) (MINGW32) published under GNU General Public License (GPL)

No issues are seen. Code compiles and resulting code is ok. (STM8 large model was not supported yet.)

1 Attachments

Discussion

  • Eric Rullens

    Eric Rullens - 2019-03-03

    This issue also is resolved by the fix made for [#2873].

     

    Related

    Bugs: #2873

  • Erik Petrich

    Erik Petrich - 2019-03-10
    • status: open --> closed-fixed
    • assigned_to: Erik Petrich
     

Log in to post a comment.

Monday.com Logo