>Synopsis: cc claims ISO C99 support, but %n printf format specifier calls
>abort()
>Category:
>Environment:
System : OpenBSD 7.2
Details : OpenBSD 7.2 (GENERIC.MP) #2: Thu Nov 24 23:54:39 MST 2022
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
Architecture: OpenBSD.amd64
Machine : amd64
>Description:
The compiler claims ISO C99 support (__STDC__ == 1 && __STDC_VERSION__ >=
199901)
but does not support the %n printf format specifier, which calls abort().
>How-To-Repeat:
Consider the following C program (tst.c):
#include <stdio.h>
int main (void)
{
int n;
#if __STDC__ == 1 && __STDC_VERSION__ >= 199901
printf ("%nhello world", &n);
#endif
return 0;
}
gcc220$ cc tst.c -o tst
tst.c:8:13: warning: '%n' format specifier support is deactivated and will call
abort(3)
printf ("%nhello world", &n);
~^
1 warning generated.
gcc220$ ./tst
Abort trap (core dumped)
>Fix:
Until %n gets implemented, __STDC__ should not be set to 1.