void foo(int x)
{
__builtin_memset(0, 0, x);
}
Compiling this with sdcc test.c -mtlcs90 results in this :
test.c:3: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '12592' : Last parameter to builtin memset() must be literal.
Contact Author with source code
Caught signal 11: SIGSEGV
Tested with commit 11672.
The same problem occurs with
__builtin_strncpy.Obviously, getting a SIGSEGV is not nice.
But how do you get to __builtin_memset on tlcs90 from standard C in the first place? The string.h header does not introduce it for tlcs90. And manually using it is undefined behaviour anyway (identifiers starting with a double underscope are reserved for the implementation).
I got this from mucking around with GCC-specific code, does SDCC just have identically named builtins that behave differently from GCC's builtins ?
I didn't know either that GCC has builtins that happen to use the same name as some SDCC ones.
In [r11676], the segfault is fixed.
One could consider that sufficient, since the behaviour is undefined anyway.
Or one could argue we need a proper error message, not one that states "Contact Author with source code". That would mean introducing some E_UNSUPPORTED_BUILTIN_USE or such.
The problem is that the error message comes from code generation in the backend. At that stage we don't know if the builtin originally came from the user invoking undefined behaviour (in which case a "normal" error message would be more appropriate) vs. a bug in machine-independent optimization (in which case the internal error is more appropriate).
Last edit: Philipp Klaus Krause 2020-06-16
Fixed in [r11677]. The underlying issue was that the tlcs90 backend, despite not supporting any builtin functions (like gbz80) announced the z80 list of builtin functions to the machine-independent parts of SDCC.