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

--- Comment #3 from Tony Reix <tony.reix at atos dot net> ---
(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?
 - GCC on Fedora/Power has made different choices for: (float, double, long
double) vs (long double) against: (char, unsigned char, unsigned short,
unsigned int). This looks incoherent. And the choice made for "long double" -->
"unsigned long" looks like a true bug.
 - Since that was working differently with GCC v6.3 on AIX vs GCC v8 & 9 on
AIX, that looks like a regression.
 - Defect https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84154 deals with the
same kind of issue, appearing in GCC 7, I think. And it was accepted and fixed.
However, it seems that only 1 patch out of 2 has been pushed.

Reply via email to