#2134 Unmatching 8052 memory type in prototype ignored


void hsk_adc_init(ubyte resolution, uword __idata convTime);

void hsk_adc_init(ubyte resolution, uword __xdata convTime) {
/* Do something. */

This will be accepted by sdcc 3.2.0 on FreeBSD and of course produces broken code for all functions that call hsk_adc_init() based on the prototype instead of the actual definition.

> sdcc --version
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.2.0 #8008 (Oct 19 2012) (FreeBSD)


  • Kamikaze Dominic Fandrey

    • labels: --> mcs51(8051) target
  • Maarten Brock

    Maarten Brock - 2013-02-20

    Is this accepted by SDCC when the compiler sees both the prototype declaration and the implementing definition? Or only when you include the prototype to sources calling the function? The linker will not check the calling convention.

  • Kamikaze Dominic Fandrey

    Both cases, I can write the unmatching prototype right above the definition into the same file or include it from a header.

    I wouldn't expect the linker to check the definition (I think no linker does that, it's kind of against the point of heaving separate headers), But if, by grace of the preprocessor, definition and declaration are both visible and unmatching, a little warning might be in order, such as occurs for type differences:
    sdcc -mmcs51 [...] -o bin.sdcc/hsk_adc/hsk_adc.rel -c src/hsk_adc/hsk_adc.c
    src/hsk_adc/hsk_adc.c:286: error 98: conflict with previous definition of 'hsk_adc_init'
    for attribute 'type'
    from type 'void function ( unsigned-char fixed, unsigned-char xdata) fixed'
    to type 'void function ( unsigned-char fixed, unsigned-int xdata) fixed'
    *** [bin.sdcc/hsk_adc/hsk_adc.rel] Error code 1

  • Maarten Brock

    Maarten Brock - 2013-02-20

    Thanks for checking. I just wanted to be sure it was no user error.

    I've set a higher priority as it silently generates wrong code.

  • Maarten Brock

    Maarten Brock - 2013-02-20
    • priority: 5 --> 6
  • Kamikaze Dominic Fandrey

    False alarm, can still reproduce.

    Last edit: Kamikaze Dominic Fandrey 2013-10-15
  • Maarten Brock

    Maarten Brock - 2013-12-25
    • Description has changed:


    --- old
    +++ new
    @@ -1,4 +1,3 @@
     void hsk\_adc\_init\(ubyte resolution, uword \_\_idata convTime\);
     void hsk\_adc\_init\(ubyte resolution, uword \_\_xdata convTime\) \{
    • status: open --> closed-fixed
    • assigned_to: Maarten Brock
    • Category: --> Front-end
  • Maarten Brock

    Maarten Brock - 2013-12-25

    Fixed in SDCC 3.3.2 #8926


Log in to post a comment.