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

            Bug ID: 86631
           Summary: [9 Regression] missing -Walloc-size-larger-than on
                    ILP32 hosts
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

As noted in pr82063, comment #15, the following tests fail on arm-none-eabi and
likely all other ILP32 targets:

FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 403)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 404)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 406)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 407)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 408)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 409)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 410)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 413)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 414)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 416)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 438)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 449)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 453)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 454)
FAIL: gcc.dg/attr-alloc_size-3.c  (test for warnings, line 455)
FAIL: gcc.dg/attr-alloc_size-3.c (test for excess errors)
FAIL: gcc.dg/attr-alloc_size-3.c argument 2 (test for warnings, line 410)
FAIL: gcc.dg/attr-alloc_size-3.c argument 2 (test for warnings, line 455)
FAIL: gcc.dg/Wvla-larger-than-3.c  (test for warnings, line 66)
FAIL: gcc.dg/pr42611.c  (test for warnings, line 17)void sink (void*);

A simple test case for the missing warning is:

void* f (__SIZE_TYPE__) __attribute__ ((alloc_size (1)));

void g (void)
{
  const unsigned long max = -1;

  sink (f (max - 1));
}

The problem is the use of HOST_WIDE_INT_MAX in c-family/c.opt:

Walloc-size-larger-than=
C ObjC C++ LTO ObjC++ Var(warn_alloc_size_limit) Joined Host_Wide_Int ByteSize
Warning Init(HOST_WIDE_INT_MAX)
-Walloc-size-larger-than=<bytes> Warn for calls to allocation functions that
attempt to allocate objects larger than the specified number of bytes.

In ILP32 it sets the limit for the warning to LLONG_MAX which is greater than
the value of PTRDIFF_MAX on the targer (the intended setting).   Unless there
is a macro that on the hosts gives the corresponding limit it might be
necessary to either reserve a value as special (such as HOST_WIDE_INT_MAX), or
to enhance the option argument parser to recognize and interpret such macros so
that Walloc-size-larger-than=PTRDIFF_MAX can be set in c.opt and interpreted to
mean the same thing regardless of the target.

Reply via email to