Menu

#3357 Wrong linkage for mcs51, hc08, stm8 on definition followed by declaration

open
nobody
None
other
5
2022-03-17
2022-03-17
No

Functions that according to the standard should have external linkage, do apparently have static linkage when there is a definition with no declaration before it, but a declaration after it, and the function is not called from the translation unit:

int func (int c)
{
    return c;
}

int func(int);

Does not result in a symbol in the .rel file. So func cannot be called from other translation units. I noticed the bug for mcs51, hc08 and stm8 using current SDCC from trunk. I could not reproduce it on z80 and pdk15.
The issue was originally brought to my attention by @felixs, who ran into it while porting some regression tests from other compilers to SDCC.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB