https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94981

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
                 CC|                            |jakub at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Tony Reix from comment #3)
> (In reply to Andreas Schwab from comment #1)
> > Converting a negative float to an unsigned integer is undefined.
> 
> Yes, I do see some comments about this in older GCC bugs.
> Like: https://gcc.gnu.org/legacy-ml/gcc/2016-02/msg00373.html
> 
> Moreover, I see that this option could help: -fsanitize=float-cast-overflow .
> 
> However, I have 4 comments:
>  - GCC on Fedora/x86_64 has made a choice (not forcing a 0 for negative
> values) that seems coherent. Why not makes the same choice everywhere in
> order to improve the portability?

No, that is not a choice, that is just one of the possible values you can get,
along with all other values the type can have, formatting your disc, crashing,
anything else.
The compiler optimizes on the assumption that UB doesn't happen, just don't
invoke it.

Reply via email to