https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108377
Bug ID: 108377
Summary: Unexpected 'exceeds maximum object size' diagnostic,
wrong-code?
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: tschwinge at gcc dot gnu.org
Target Milestone: ---
Created attachment 54249
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54249&action=edit
1.c
Am I confused (it's late), or is GCC? For '-O2' and higher:
1.c: In function ‘f’:
1.c:22:12: warning: argument 1 value ‘18446744073709551615’ exceeds maximum
object size 9223372036854775807 [-Walloc-size-larger-than=]
22 | needle = __builtin_malloc(n); /* { dg-bogus {exceeds maximum
object size} } */
| ^~~~~~~~~~~~~~~~~~~
1.c:22:12: note: in a call to built-in allocation function
‘__builtin_malloc’
Manually reduced from some other test case.
Same issue for actual 'malloc', and 'size_t'.
This supposedly bogus 'needle' diagnostic disappears if I disable the
'haystack' allocation of 'n + 1'.
Actually, is this wrong-code?
1.c.128t.sra: _2 = __builtin_malloc (_1);
1.c.128t.sra: _5 = __builtin_malloc (n_14);
1.c.129t.thread1: _2 = __builtin_malloc (_1);
1.c.129t.thread1: _10 = __builtin_malloc (n_14);
1.c.129t.thread1: _5 = __builtin_malloc (n_14);
1.c.130t.dom2: _2 = __builtin_malloc (_1);
1.c.130t.dom2: _10 = __builtin_malloc (18446744073709551615);
1.c.130t.dom2: _5 = __builtin_malloc (n_14);
[...]
1.c.194t.fre5: _2 = __builtin_malloc (_1);
1.c.194t.fre5: _10 = __builtin_malloc (18446744073709551615);
1.c.194t.fre5: _5 = __builtin_malloc (n_14);
1.c.195t.thread2: _2 = __builtin_malloc (_1);
1.c.195t.thread2: _10 = __builtin_malloc (18446744073709551615);
1.c.195t.thread2: _33 = __builtin_malloc (n_14);
1.c.195t.thread2: _5 = __builtin_malloc (n_14);
1.c.196t.dom3: _2 = __builtin_malloc (_1);
1.c.196t.dom3: _10 = __builtin_malloc (18446744073709551615);
1.c.196t.dom3: _33 = __builtin_malloc (i_51);
1.c.196t.dom3: _5 = __builtin_malloc (0);
[...]
1.c.254t.optimized: _2 = __builtin_malloc (_1);
1.c.254t.optimized: _10 = __builtin_malloc (18446744073709551615);
1.c.254t.optimized: _33 = __builtin_malloc (i_51);
1.c.254t.optimized: _5 = __builtin_malloc (0);