A: a new bug to old plain C

Jonathan Wakely jwakely.gcc@gmail.com
Sat Nov 22 18:36:48 GMT 2025


On Sat, 22 Nov 2025, 15:18 Александр Поваляев, <apovalyaev@gmail.com> wrote:

> Hi there!
>
> The links you posted are all about "Don't use Foo** → const Foo**, use const
> Foo** to const Foo* const* conversion instead"
> (https://isocpp.org/wiki/faq/const-correctness#constptrptr-conversion,
> https://c-faq.com/ansi/constmismatch.html).
> Also, it is being discussed if it is safe or not to use such kind of
> conversion.
>
> But we don't use "Foo** -> const Foo**" conversion anyhow.
> We use "Foo** -> const Foo * const * const" conversion. So, we just follow
> the recommendation given and not the opposite. :)
>


And so your code would compile in C++.

But like it says in the C FAQ, the rules for C and C++ are different. C
does not allow that conversion, even though it would be safe (and C++ does
allow it).

Here is the relevant part:

"C++ has more complicated rules for assigning const-qualified pointers
which let you make more kinds of assignments without incurring warnings,
but still protect against inadvertent attempts to modify const values. C++
would still not allow assigning a char ** to a const char **, but it would
let you get away with assigning a char ** to a const char * const *.)"





> Anyway some compilers return an error. And this is not the expected
> behaviour for use. It is A BUG!!!
>

OK, maybe try a different compiler then.




>
>>>
>>>


More information about the Gcc-help mailing list