A: a new bug to old plain C
Andrey Tarasevich
atarasevich@comcast.net
Sat Nov 29 07:18:26 GMT 2025
No, no, no... You just keep piling up misconceptions.
First and foremost, the third (the last) 'const' in your parameter
declaration is completely inconsequential in our context (i.e. for conversion
purposes). It is ignored by the compiler. It makes no difference
whatsoever, which is why I removed it from my minimalistic example - to
avoid unnecessary clutter. My example is exactly 100% equivalent to
yours and, of course, exactly as relevant. Mine is just way more compact.
Moreover, your statement "We're discussing 'Foo**'->'const Foo * const *const'
conversion (all-consts)..." is downright nonsensical in formal C terminology.
In C language all conversions produce _rvalues_ (!). Rvalues cannot be
'const' in C. Qualifications do not apply to rvalues in C at all
(see
https://port70.net/~nsz/c/c11/n1570.html#6.7.3p4). The last 'const'
in your example, once again, makes no difference and is completely
ignored by the compiler for conversion purposes.
So, no, we are talking about conversion
'Foo** -> const Foo * const *' (note: last 'const' removed as irrelevant).
And, as I explicitly told you in my first response, this conversion is
_not_ supported in C language as an _implicit_ conversion. End of story.
(BTW, GCC tends to quote that irrelevant third 'const' in its diagnostic
messages, while Clang removes it. Take a closer look at Clang's
diagnostics for your example.)
Your experiments with different compilers and builds are completely
beside the point. Not sure what point you are trying to make with them,
considering what has already been explained to you. That said, you did find
a bug in one compiler: in Intel's one. As I have already stated
previously, Intel's silent behavior in this case is non-compliant. As
for GCC and Clang... their behavior is perfectly correct: they do issue the
required diagnostic for this constraint violation.
--
Best regards,
Andrey
P.S. As it has already been mentioned by other posters, there are proposals
aiming to permit this implicit conversion in C (just like it is permitted
in C++). But we are not there yet. In C23 your code is still invalid.
More information about the Gcc
mailing list