Dear All,

Since a while I see that sdcc rejects code constructs such as:

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

error 2: Initializer element is not a constant expression (with sdcc 3.8.5
#10914)
===

It used to compile fine with e.g. sdcc 3.6.3 #9791.

In another case an almost identical construct is accepted, but the resulting
code is wrong. Well... it's not there... :)

===
int f2(void)
{
  /* Expect 3 + 3 = 6 to be returned. But no code is generated. (3.8.5.
#10914) */
  return (2 ? 3 : 4) + (2 ? 3 : 4);
}

                                    141 ;       test.c: 57: int f2(void)
                                    142 ;
-----------------------------------------
                                    143 ;        function f2
                                    144 ;
-----------------------------------------
      010059                        145 _f2:
                                    146 ;       test.c: 60: return (2 ? 3 :
4) + (2 ? 3 : 4);
                                    147 ;       test.c: 62: }
      010059 87               [ 5]  148         retf
===

Both compiled using the STM8 large memory model target. A quick test with
MCS51 large memory model shows the same result for the first issue, but the
second issue does not seem to be present (I see a mov dpl,#0x06 in the
generated code).

In the bugtracker I saw some activity on issues also involving the ternary
operator (e.g. bug 2535), but I'm not sure if these are related.

What do you think? If it looks like a new bug (or bugs), I can file it.

 Eric


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to