This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug sanitizer/81986] sanitizer detects negation of large number in string.c


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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Vittorio Zecca from comment #2)
> I do not know if this is a libgfortran or a sanitizer bug.
> 
> What I do know is that changing string.c:199 from
> 
> t = - n;
> 
> into
> 
> t = -(GFC_UINTEGER_LARGEST)n;

This is of course the right fix, negation of smallest signed number is UB in C,
while it is well defined when the negation is performed in corresponding
unsigned type.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]