AaronBallman wrote:

> The validation of %b and %B was done without taking into account the current 
> language mode, which means that %b and %B could have been used in format 
> strings before they were supported.

On the one hand, yes, this is correct. On the other hand, a C23-based standard 
library is not going to know that the host application was compiled in C17 mode 
and it may very well support these modifiers: https://godbolt.org/z/G7KdeKqEx 
So the issue is that in C23 mode, we can assume the standard library is 
C23-compatible, but in pre-C23 modes, we can't make assumptions one way or the 
other.

So I think we don't want to treat the modifiers as being unknown. Instead, I 
think we should issue a diagnostic along the lines `format specifier '%b' 
requires a C standard library that is compatible with C23; data argument may 
not be used by format`. I think this is a different kind of incompatibility 
than we've had before, so it may require more invasive changes. However, we'll 
need this for other format specifiers like `%wN` and `%wfN`.

https://github.com/llvm/llvm-project/pull/126694
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to