This falls into the catagory of "bummer".

We will continue to break all applications that use %n, because we
haven't found a single use of %n is that is safe. and %n uses are
completely trivial to replace.

There are almost no %n left in the software ecosystem.  If we are able
to make this crossing, everyone else is also capable, and eventually
will.  Just like with gets().

So we will not follow your proposal, because your proposal will break
thousands of other things, rather than our intented behaviour of being
safe.


The future doesn't get better if you demand backwards compatibility
forever.  The Unix landscape is getting old enough to throw bad ideas
out.


[email protected] wrote:

> >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.
> 

Reply via email to