public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/67379] New: libgcc2.c negation of -2147483648 cannot be represented in type 'int'
@ 2015-08-28  8:39 zeccav at gmail dot com
  2015-08-28  9:32 ` [Bug libgcc/67379] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: zeccav at gmail dot com @ 2015-08-28  8:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67379
           Summary: libgcc2.c negation of -2147483648 cannot be
                    represented in type 'int'
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zeccav at gmail dot com
  Target Milestone: ---

In libgcc2.c:1842

int m;
unsigned int n = m < 0 ? -m : m;

when m==-2147483648

I get the following message from the sanitizer

/home/vitti/gcc-5.2.0/libgcc/libgcc2.c:1842:31: runtime error: negation of
-2147483648 cannot be represented in type 'int'; cast to an unsigned type to
negate this value to itself

I suggest changing the line to the correct version

unsigned int n = m < 0 ? - (unsigned int) m : m;

to avoid undefinite behaviour

This is running the gfortran testsuite file integer_exponentiation_1.f90


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-27  8:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-28  8:39 [Bug libgcc/67379] New: libgcc2.c negation of -2147483648 cannot be represented in type 'int' zeccav at gmail dot com
2015-08-28  9:32 ` [Bug libgcc/67379] " rguenth at gcc dot gnu.org
2015-09-07  7:40 ` zeccav at gmail dot com
2021-02-27  8:48 ` zeccav at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).