A: a new bug to old plain C

Александр Поваляев apovalyaev@gmail.com
Sat Nov 22 15:18:35 GMT 2025


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. :)

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

Respectfully,
Aleksandr G Povaliaev.


пт, 21 нояб. 2025 г. в 23:16, Jonathan Wakely <jwakely.gcc@gmail.com>:

>
>
> On Fri, 21 Nov 2025, 17:48 Александр Поваляев via Gcc-help, <
> gcc-help@gcc.gnu.org> wrote:
>
>> Hi there!
>>
>> Per my understanding it should work fine! Some compilers do work fine.
>> Some
>> compilers don't. So, this is "NON STABLE" behaviour.
>> I am wondering why nobody else has reported this BUG before!!!
>>
>
> It's not a bug.
>
>
>
>> The use-case is pretty simple: we are iterating over an array (I mean
>> 'plain old C array).
>> And so, we need a final point of iteration (end_ptr).
>>
>> In case of array ('plain old C array') of, let's say, integers, it would
>> look like this: "const int * const end_of_iteration = array_ptr + count".
>> And in case of array of pointers, it looks like: "const int * const *
>> const
>> end_of_iteration = array_ptr + count".
>>
>> Respectfully,
>> Aleksandr G Povaliaev.
>>
>>
>> пт, 21 нояб. 2025 г. в 06:24, Chris S <cs2991@gmail.com>:
>>
>> > You're applying two consts to the same thing, so it's an error.
>> >
>> > "Const int" and "int const" are the same (look up East vs West const),
>> but
>> > "const int const" is an error.  Declaring a pointer to that invalid type
>> > declaration is still invalid.
>> >
>> > On Thu, Nov 20, 2025, 5:27 PM Александр Поваляев via Gcc-help <
>> > gcc-help@gcc.gnu.org> wrote:
>> >
>> >> struct zzz {
>> >> unsigned x, y;
>> >> };
>> >>
>> >> void square(struct zzz ** arr_of_ptr, unsigned count) {
>> >>
>> >> *// The first "const" produce an error (not a warning) within some GCC
>> >> toolchains, for example ARM GCC trunk (linux), see goldbolt.org
>> >> <http://goldbolt.org>*
>> >> struct zzz const * const * const end_of_arr = arr_of_ptr + count;
>> >>
>> >> *// Without the first const "struct zzz * const * const end_of_arr =
>> >> arr_of_ptr + count;" it works fine!!!*
>> >>
>> >> }
>> >>
>> >> Respectfully,
>> >> Aleksandr G Povaliaev.
>> >>
>> >
>>
>


More information about the Gcc-help mailing list