Bug 90819 - [10 regression] -Walloc-size-larger-than error in trans-mem.c
Summary: [10 regression] -Walloc-size-larger-than error in trans-mem.c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: 10.0
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-10 18:01 UTC by Rainer Orth
Modified: 2019-06-11 09:07 UTC (History)
1 user (show)

See Also:
Host:
Target: i386-pc-solaris2.11, sparc-sun-solaris2.11
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-06-10 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2019-06-10 18:01:52 UTC
This patch

2019-06-10  Martin Liska  <mliska@suse.cz>

        * ansidecl.h:
        (ATTRIBUTE_RESULT_SIZE_1): Define new macro.
        (ATTRIBUTE_RESULT_SIZE_2): Likewise.
        (ATTRIBUTE_RESULT_SIZE_1_2): Likewise.
        * libiberty.h (xmalloc): Add RESULT_SIZE attribute.
        (xrealloc): Likewise.
        (xcalloc): Likewise.

broke bootstrap on Solaris/x86 and Solaris/SPARC (and probably other 32-bit
targets):

In file included from /vol/gcc/src/hg/trunk/local/gcc/system.h:691,
                 from /vol/gcc/src/hg/trunk/local/gcc/trans-mem.c:23:
In function 'void tm_memopt_compute_available(tm_region*, vec<basic_block_def*>)',
    inlined from 'unsigned int execute_tm_memopt()' at /vol/gcc/src/hg/trunk/local/gcc/trans-mem.c:4047:35,
    inlined from 'virtual unsigned int {anonymous}::pass_tm_memopt::execute(function*)' at /vol/gcc/src/hg/trunk/local/gcc/trans-mem.c:4087:72:
/vol/gcc/src/hg/trunk/local/gcc/../include/libiberty.h:362:39: error: argument 1 value '4294967292' exceeds maximum object size 2147483647 [-Werror=alloc-size-larger-than=]
  362 | #define XNEWVEC(T, N)  ((T *) xmalloc (sizeof (T) * (N)))
      |                               ~~~~~~~~^~~~~~~~~~~~~~~~~~
/vol/gcc/src/hg/trunk/local/gcc/trans-mem.c:3713:5: note: in expansion of macro 'XNEWVEC'
 3713 |     XNEWVEC (basic_block, qlen);
      |     ^~~~~~~
In file included from /vol/gcc/src/hg/trunk/local/gcc/system.h:691,
                 from /vol/gcc/src/hg/trunk/local/gcc/trans-mem.c:23:
/vol/gcc/src/hg/trunk/local/gcc/../include/libiberty.h: In member function 'virtual unsigned int {anonymous}::pass_tm_memopt::execute(function*)':
/vol/gcc/src/hg/trunk/local/gcc/../include/libiberty.h:313:14: note: in a call to allocation function 'void* xmalloc(std::size_t)' declared here
  313 | extern void *xmalloc (size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_RESULT_SIZE_1 ATTRIBUTE_WARN_UNUSED_RESULT;
      |              ^~~~~~~
Comment 1 Jakub Jelinek 2019-06-10 21:35:14 UTC
Yeah, I see it too.  The caller guarantees blocks.length () is at least 1 (as it always pushes entry_block in there), so in
  qlen = blocks.length () - 1;
  qin = qout = worklist =
    XNEWVEC (basic_block, qlen);
qlen is never -1U, but the compiler doesn't know this.
Comment 2 Jakub Jelinek 2019-06-10 21:36:06 UTC
Testing patch for this.
Comment 3 Martin Liška 2019-06-11 07:31:50 UTC
Thank you Jakub.
Comment 4 Jakub Jelinek 2019-06-11 08:20:34 UTC
Author: jakub
Date: Tue Jun 11 08:20:02 2019
New Revision: 272145

URL: https://gcc.gnu.org/viewcvs?rev=272145&root=gcc&view=rev
Log:
	PR bootstrap/90819
	* trans-mem.c (tm_memopt_compute_available): Add assertion
	that blocks is not empty.  Formatting fix.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/trans-mem.c
Comment 5 Richard Biener 2019-06-11 09:07:32 UTC
Fixed.