Loss of qualifiers from pointer target is not reported in cases of array-to-pointer decay
The issue also manifests when the array whose type decays to a pointer is a member of a struct: struct SAC { char m[64]; }; void str_from_struct(_Optional const struct SAC *pocs) { static_assert(_Generic(pocs->m, const char *: 1, default: 0)); // FAIL: static assertion failed }
Array to pointer conversion does not remove the _Optional qualifier from the element type
After further investigation, I don't think this bug is specific to _Optional: void f(void *t); void g(char *t); void h(int *t); void foo(void) { volatile char *t = 0; f(t); // undiagnosed violation g(t); // undiagnosed constraint violation h(t); // undiagnosed violation const char *s = 0; f(s); // undiagnosed constraint violation g(s); // diagnosed constraint violation h(s); // undiagnosed violation }
Missing diagnostic when qualifier is discarded from pointer target on function call
Wrong diagnostic message when adding 0 to a pointer to an _Optional type
No diagnostic message when subtracting 0 from a pointer to an _Optional type
I retested this with a newer build of SDCC and it still reports a syntax error, but the warning about a missing return type appears to have been fixed: ~/optional-ts/examples $ sdcc -c --std=c23 3916.c 3916.c:2: error 1: Syntax error, declaration ignored at ')' Internal error: validateLink failed in SPEC_NOUN(p) @ SDCCsymt.c:706: expected SPECIFIER, got null-link ~/optional-ts/examples $ sdcc -c --std=c23 --stack-auto 3916.c 3916.c:2: error 1: Syntax error, declaration ignored at ')' Internal error:...