In current SDCC, this code:
static int cmp_eq (long arg1, long arg2)
{
return arg1 != arg2;
}
struct op {
const char *op_name;
void *op_func;
};
const struct op string_binop[] = {
{"=", (void *)cmp_eq},
};
fails to compiler for z80 (and most likely theother backends, too):
test.c:12: error 129: pointer types incompatible
from type 'void generic* fixed'
to type 'void generic* fixed'
This pointer type incompatibility stuff has become a major issue. It prevents building of at least two OSes with SDCC: FUZIC and NuttX.
Philipp
Apparently, initValPointer() in SDCCglue.c returns 0, resulting in the error.
Philipp
P.S.: Or rather, the bug is that constExprValue() returns 0, even though is it supposed to return nonzero values for constant expressions (Iguess as identified by constExprTree() above).
Last edit: Philipp Klaus Krause 2017-10-05
By the C standard, we don't have to allow casts from pointers to functions to pointers to objects, so this bug seems to be not that big of an issue.
Philipp
However, one of the types reported in the error message is wrong, so even if we want to disallow such casts, there is still a bug here.
Philipp
Last edit: Philipp Klaus Krause 2017-10-05
As of revision [r10036], the fix for bug #2641 changed the error message. SDCC no longer claims that the pointer type is incompatible with itself, instead stating that the initializer is not a constant expression.
Ideally, if SDCC rejects the code it should complain about a pointer to a function type being cast to a pointer to an object type.
Philipp