[Bug target/109236] [avr] Invalid code of signed 16-bit compare optimization

2023-03-21 Thread gandalf at winds dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109236

gandalf at winds dot org changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|UNCONFIRMED |RESOLVED

--- Comment #2 from gandalf at winds dot org ---
Thank you, I hadn't thought of that at all. That was precisely my problem and I
developed a work-around. Not a bug.

[Bug target/109236] [avr] Invalid code of signed 16-bit compare optimization

2023-03-21 Thread dimitar at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109236

Dimitar Dimitrov  changed:

   What|Removed |Added

 CC||dimitar at gcc dot gnu.org

--- Comment #1 from Dimitar Dimitrov  ---
Pass the -Wstrict-overflow=4 option to GCC and see that compiler assumes no
integer overlow will happen:

test.c:3:12: warning: assuming signed overflow does not occur when simplifying
'X - Y <= 0' to 'X <= Y' [-Wstrict-overflow]
3 |   return (x-y <= 0);


Consider using "__builtin_sub_overflow" for a strictly defined behaviour when
integer overflow happens.