On Tue, Jun 28, 2022 at 11:38 PM Alexander Monakov <amonakov@xxxxxxxxx> wrote: > On Tue, 28 Jun 2022, Adonis Ling via Gcc-help wrote: > > > > Here the main problem is '*array' and 'nread' have the same type, so > they > > > might overlap. Ideally the compiler would recognize that that cannot > happen > > > because it would make 'array[nread++] = i' undefined due to unsequenced > > > modifications, but GCC is not sufficiently smart (yet). The secondary > issue > > > is the same as below: > > > > > > > I got your point. > > > > After that, I tried to add __restrict__ to nread as the following shows > and > > GCC still doesn't optimize it. > > As I said, there's a secondary issue even if you add 'restrict'. > > Alexander > For the secondary issue, could I explain that Clang chooses to ignore it? -- Best regards, Adonis