#1531 Internal error: validateLink failed in SPEC_BLEN

closed-fixed
nobody
5
2013-05-25
2009-04-27
BsAtHome
No

Double dereference on an array of pointers addressing a bitfield causes an internal error.

See code below. Compiled with:
$ sdcc/bin/sdcc -mpic16 -p18f2550 -obitfield bitfield.c
Internal error: validateLink failed in SPEC_BLEN(operandType(result)) @ /home/sdcc-builder/build/sdcc-build/orig/sdcc/src/pic16/gen.c:8202: expected SPECIFIER, got DECLARATOR

Versions tried:
- 2.8.0 (Fedora 9 stock)
- sdcc-snapshot-i386-unknown-linux2.5-20090427-5436.tar.bz2

--- begin code bitfield.c ---
struct bitfield {
unsigned bit:1;
} *bla[1];

void func(void)
{
if(bla[0]->bit)
bla[0]->bit = 0;
}
--- end code bitfield.c ---

--
Greetings Bertho

Discussion

  • BsAtHome
    BsAtHome
    2009-04-27

    Please note that declaration in the above example as "**bla" instead of "*bla[1]" would not fail. Being a bit creative in the dereference and specifying (*(*(bla+0))).bit would lead to the same internal error.

    So, the conclusion would be that the array declaration is the culprit. This is a bit odd because the C language does not distinguish between the two semantically for all dereferencing purposes. The only difference is the allocation of storage, but that is not at issue at dereferencing time, unless static compile time buffer overrun is being checked (but this can still be done for either declaration syntax).

    --
    Greetings Bertho

     
  • Raphael Neider
    Raphael Neider
    2009-04-27

    Fixed in sdcc 2.9.1, r5439.
    Thank you for the stripped down failing code sample and the report!

     
  • Raphael Neider
    Raphael Neider
    2009-04-27

    • milestone: --> fixed
    • status: open --> closed-fixed
     
  • BsAtHome
    BsAtHome
    2009-04-27

    This is a nice surprise; 69 minutes from report to fix. I guess you are too far away to give you a beer in the bar around the corner.

    I'll test the autobuild asap.Thank you.

    --
    Greetings Bertho