Menu

#4000 Spurious "block-scope variable'i' declared extern and intialized"

open
nobody
None
other
5
2026-06-03
2026-06-03
No

1: Sample code that reproduces the problem.

int f2(void);

int main(void)
{
  typeof(f2()) i = 3;
  i = 2;
  return i;
}

2: Exact command used to run SDCC on this sample code

sdcc -c --std=c23 --stack-auto test.c

3: SDCC version tested (type "sdcc -v" to find it)

SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/r4k/r5k/r6k/sm83/tlcs90/ez80/z80n/r800/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502/mos65c02/f8/f8l TD- 4.5.24 #16456 (Mac OS X ppc)
published under GNU General Public License (GPL)

4: Copy of the error message or incorrect output, or a clear description of the observed versus expected behavior.
The output is:

test.c:5: error 320: block-scope variable'i' declared extern and intialized

I don't think the variable should be considered 'extern' because 'extern' isn't part of the type of the return value of f2(). The error message also seems to contain errors.

Discussion


Log in to post a comment.

Auth0 Logo