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 c/81650] New: gcc -m32 mishandles -Walloc-size-larger-than=9223372036854775807


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

            Bug ID: 81650
           Summary: gcc -m32 mishandles
                    -Walloc-size-larger-than=9223372036854775807
           Product: gcc
           Version: 7.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at gnu dot org
  Target Milestone: ---

This is following up a Gnulib bug report:

http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00150.html

which appears to stem from a bug in GCC. To reproduce the problem, compile the
following program:

extern void *malloc (unsigned long);
int
main (void)
{
  return !malloc (5);
}

with this shell command:

gcc -m32 -Walloc-size-larger-than=9223372036854775807 -S foo.c

On Fedora 26, gcc 7.1.1 20170622 (Red Hat 7.1.1-3) outputs the following false
alarm:

foo.c: In function 'main':
foo.c:5:11: warning: argument 1 value '5' exceeds maximum object size -1
[-Walloc-size-larger-than=]
   return !malloc (5);
           ^~~~~~~~~~
foo.c:1:14: note: in a call to allocation function 'malloc' declared here
 extern void *malloc (unsigned long);
              ^~~~~~

GCC works correctly (i.e., silently) if -m32 is omitted. Evidently GCC is not
doing the right thing when the operand of -Walloc-size-larger-than is too
large: such an operand should be treated as infinity, not as -1.

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