Menu

#3917 FATAL Compiler Internal Error caused by typeof_unqual on function (pointer) type names

open
nobody
None
other
5
2026-01-08
2026-01-08
No

Neither function type names nor function pointer type names can be used as the operand of the typeof_unqual operator.
Clang and LLVM permit it: https://godbolt.org/z/vY3P4ds4o
I would expect SDCC to permit it too.
If this is not addressed then this method of declaring pointers to optional-qualified function types will be unavailable to SDCC users, e.g. _Optional typeof_unqual (int (int)) *opf;
(I'm not sure why anyone would use typeof_unqual instead of typeof, but the fact remains.)

  1. Sample code that reproduces the problem:
int foo(int);
typeof_unqual (int (*)(int)) pfoo; // FATAL Compiler Internal Error
typeof_unqual (int (int)) foo; // FATAL Compiler Internal Error
typeof_unqual (int (int)) *pfoo; // FATAL Compiler Internal Error
  1. Exact command used to run SDCC on this sample code:
    sdcc --std=c23 bug2.c

  2. SDCC version tested:
    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.15 #15966 (Linux)
    published under GNU General Public License (GPL)

Also tested version 4.5.0 at Compiler Explorer.

  1. Copy of the error message or incorrect output:
    bug2.c:2: error 9: FATAL Compiler Internal Error in file 'SDCC.y' line number '833' : code generator internal error
    Contact Author with source code
    Internal error: validateLink failed in SPEC_NOUN((yyval.lnk)) @ SDCC.y:834: expected SPECIFIER, got DECLARATOR

Discussion


Log in to post a comment.