Re: A: a new bug to old plain C

Александр Поваляев via Gcc-h elp <[email protected]>
Newsgroups gmane.comp.gcc.help
Message-ID <CAGT+J5zXSraR+HVzqpQJ-iA96VU7ikpHfG6L3p3MeXwa52HBXg@mail.gmail.com>
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 <[email protected]>:

>
>
> On Fri, 21 Nov 2025, 17:48 Александр Поваляев via Gcc-help, <
> [email protected]> 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 <[email protected]>:
>>
>> > 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 <
>> > [email protected]> 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.
>> >>
>> >
>>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.