On Wed, 11 May 2022, Joseph Myers wrote:

I'd also like to check that "if mingw-w64 is configured to target UCRT" is
not something that is necessarily known when GCC is built or from the
command-line options passed to GCC.  Because ideally one might expect the
TARGET_OVERRIDES_FORMAT_ATTRIBUTES / TARGET_OVERRIDES_FORMAT_INIT
definitions to handle things appropriately conditionally, so that printf
attributes are handled as gnu_printf for the "if mingw-w64 is configured
to target UCRT" case.  Disregarding a built-in format attribute when one
is also specified explicitly in the header, even though the two are not
exactly equivalent attributes, as in this patch, seems more like the right
approach in the case where the attributes in installed header (at the time
GCC is run, not the time it is built) *are* the way in which GCC gets the
"configured to target UCRT" information - as opposed to it being something
available before the header is parsed.

Indeed, the "configured to target X" information isn't available at the point when GCC is built - that gets set afterwards. And even while it is usually mostly fixed soon afterwards, you can even (with some amount of gotchas) change what CRT to build for by passing the appropriate defines that picks a different default in the mingw-w64 headers.

Anyway - from the GCC point of view, it's not fixed, and whatever the parsed headers say, is the only thing that can be relied upon. So I think the approach of the patch is the right one, code style/issues notwithstanding.

// Martin

Reply via email to