[Bug c++/118720] Bug with unsigned ints

2025-02-12 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #12 from Jonathan Wakely --- I commented on github with a standard reference. The behaviour is undefined.

[Bug c++/118720] Bug with unsigned ints

2025-02-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 Andrew Pinski changed: What|Removed |Added See Also||https://github.com/jeaiii/i

[Bug c++/118720] Bug with unsigned ints

2025-02-11 Thread ddgreen at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #10 from Daniel Green --- Created attachment 60467 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60467&action=edit Second testcase

[Bug c++/118720] Bug with unsigned ints

2025-02-11 Thread ddgreen at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #9 from Daniel Green --- Sorry for bringing this up again, but here is a comment by the guy who originally created the code (full thread here https://github.com/jeaiii/itoa/issues/17#issuecomment-2652085888) and another example (http

[Bug c++/118720] Bug with unsigned ints

2025-02-02 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #8 from Jonathan Wakely --- Did you adjust the code to use std::span? I didn't say that just adding -fhardened will diagnose anything. My point is that using std::span instead of char* will make b-1 ill-formed, and b[-1] will abort.

[Bug c++/118720] Bug with unsigned ints

2025-02-02 Thread ddgreen at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #7 from Daniel Green --- (In reply to Jonathan Wakely from comment #6) > std::span should diagnose it with -fhardened I couldn't get `-fhardened` to complain either on godbolt or locally (with gcc 14.2.0). I tried `-O0`, `-O1`, `-O3

[Bug c++/118720] Bug with unsigned ints

2025-02-02 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #6 from Jonathan Wakely --- std::span should diagnose it with -fhardened

[Bug c++/118720] Bug with unsigned ints

2025-01-31 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #5 from Andrew Pinski --- (In reply to Daniel Green from comment #4) > > Huh, annoying that `-fsanitize=undefined` doesn't pick up on it. It is hard to pick up as it requires inlining . I will file a bug requesting an enhancement

[Bug c++/118720] Bug with unsigned ints

2025-01-31 Thread ddgreen at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #4 from Daniel Green --- (In reply to Andrew Pinski from comment #3) > b -= n < (uint32_t)(10); > > Can produce undefined behavior. because now you are doing `work-1` which is > before the array. > > ``` > static constexpr void

[Bug c++/118720] Bug with unsigned ints

2025-01-31 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|---

[Bug c++/118720] Bug with unsigned ints

2025-01-31 Thread ddgreen at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #2 from Daniel Green --- (In reply to Andrew Pinski from comment #1) > Created attachment 60347 [details] > testcase > > Next time don't just link to godbolt but either attach the testcase or put > it inline. Ah, sorry, I thought a

[Bug c++/118720] Bug with unsigned ints

2025-01-31 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118720 --- Comment #1 from Andrew Pinski --- Created attachment 60347 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60347&action=edit testcase Next time don't just link to godbolt but either attach the testcase or put it inline.