Re: A: a new bug to old plain C
Jonathan Wakely via Gcc-help <[email protected]>
| Newsgroups | gmane.comp.gcc.help |
|---|---|
| Message-ID | <CAH6eHdQ9Cu_U1jx8yNTjDwNY7zyQQSf6XcZAYukQKKrb9N-Www@mail.gmail.com> |
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. > >> > > >