[Bug middle-end/105424] Bogus -Wstringop-overread with non-overread condition

2022-04-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105424

Andrew Pinski  changed:

   What|Removed |Added

 Status|WAITING |UNCONFIRMED
 Ever confirmed|1   |0

[Bug middle-end/105424] Bogus -Wstringop-overread with non-overread condition

2022-04-28 Thread byteslice at airmail dot cc via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105424

--- Comment #3 from Liam White  ---
Compile with c++ -std=gnu++20 -O1 -Werror=stringop-overread to reproduce.

[Bug middle-end/105424] Bogus -Wstringop-overread with non-overread condition

2022-04-28 Thread byteslice at airmail dot cc via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105424

Liam White  changed:

   What|Removed |Added

  Attachment #52897|0   |1
is obsolete||

--- Comment #2 from Liam White  ---
Created attachment 52901
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52901=edit
Preprocessed source

[Bug middle-end/105424] Bogus -Wstringop-overread with non-overread condition

2022-04-28 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105424

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
 Ever confirmed|0   |1
   Last reconfirmed||2022-04-28

--- Comment #1 from Andrew Pinski  ---
> long n(end_raw - beg_raw);
> if (n < 4)

This means n could be negative which then converted to unsigned would be a
large #.

The code here is reduced too much though:
  value_type *dest_raw, *beg_raw = movelib::iterator_to_raw_pointer(f),
*end_raw = 0;

So basically you have (long)(beg_raw) < 4. Which might be true if the upper bit
is set.

Please attach the original preprocessed source as I have shown it was reduced
too much.


Plus I suspect adding a check for "n >= 0" will fix the warning too.