A: a new bug to old plain C
David Brown
david.brown@hesbynett.no
Wed Nov 26 15:23:40 GMT 2025
On 26/11/2025 07:14, Александр Поваляев via Gcc-help wrote:
> Hi there! So, any update on this?
>
> Could somebody point out where in the C standard a conversion "Foo**" ->
> "const Foo * const * const" is prohibited?
> Any link? Some quote from any book on C language?
>
The C standard does not describe what is prohibited - it describes what
is /allowed/. Get a copy of whatever version of the C standard you want
to use (draft versions are freely available that are virtually identical
to the official costly versions). Read about compatible types, and
assignment operators. Since the conversion you want does not match any
of the allowed constraints for the initialisation (which follows the
rules of assignments), it is not allowed.
You are not going to find a list of all the things the C standard does
not allow - that would be never-ending.
If you prefer a reference webpage, look at this :
<https://en.cppreference.com/w/c/language/operator_assignment.html>
<https://en.cppreference.com/w/c/language/compatible_type.html#Compatible_types>
That site is not the standard itself, but it is maintained in
collaboration with the C and C++ standards committees, and provides the
same information in a format that is usually a little easier to read.
You seem to be under the impression that people are telling you not to
write your code because it is "unsafe", or giving opinions about how we
like to write code. We are telling you the /facts/ about what implicit
conversions are allowed and disallowed, according to the C standards.
No one cares about whether you think your code is "safe" or not. No one
cares that your code is valid C++ - it is not correct C code, and
conforming C compilers are /required/ to complain about it.
Some other shitty C compiler might complain about it and yet still let
you compile the bad code. Or maybe you have no idea how to use your
tools correctly, and have been using other C++ compilers instead of C
compilers. The GCC /C/ compiler rejects your code because it is
incorrect code - the C standards do not allow it. And there is /zero/
chance that someone is going to break the GCC C compiler here just to
support your misconceptions.
Ironically, I believe there is a proposal to change some of these
compatible type rules to bring C more in line with C++ in regards to
"const" and pointers. So when the next C standard comes out, there's a
good chance that your code will be valid - for C2y onwards, but still
not for C23 or earlier (it's a new feature, not a backwards-working
defect report). Since you are so unwilling to learn anything here,
perhaps your best course of action would be to take a break from C
programming for a few years, then update your tools and try again.
Perhaps by 2029 or 2030, that new standard will be published and gcc
will use it by default, thus "fixing" the problem in your code. (It
won't fix the major problem - your inability to comprehend anything
people tell you.)
More information about the Gcc-help
mailing list