#1610 Arrays of _Bool are very broken


Unfortunately my implementation of _Bool recently added to sdcc is broken. Fortunately it seems there is only one broken aspect, but that one is really broken: Arrays of _Bool.

Three problems:

1) Global arrays of _Bool are not correctly initialized, i.e. the initializers are not cast to _Bool:

const _Bool foo[2] = {1, 2};

will store 2 in foo[2] isntead of one (same problem for non-const array.

2) Accesses to the array access the array's address instead, i.e. reading foo[1] generates code to read the upper byte of foo's address.

3) Lokal definitions of arrays of _Bool with initializers crash the compiler.


The attached file shows the problems, I tired compiling with sdcc --std-c99 -mz80

These bugs are not located in a backend.


  • Philipp Klaus Krause

    Broken arrays of _Bool

  • Philipp Klaus Krause

    This shall be a bug report about just problems 2) and 3).

    Upon closer investigation problem 1) is different: It does not affect const arrays of bool and it does affect arrays of type other than bool. I'll file a separate bug report about that one.


  • Philipp Klaus Krause

    • priority: 5 --> 7
  • Philipp Klaus Krause

    Increasing priority, since for 2) bad code is silently generated.


  • Philipp Klaus Krause

    • labels: --> Icode generator
    • assigned_to: nobody --> spth
    • status: open --> closed-fixed
  • Philipp Klaus Krause

    Fixed in sdcc revision #6869.



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks