https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94541
Bug ID: 94541
Summary: -mx32 gcc produces wrong code passing structs by value
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: ibuclaw at gdcproject dot org
Target Milestone: ---
Created attachment 48250
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48250&action=edit
test case
Attached reduced example.
Compiled with 'g++ -Wall -Wextra -fno-strict-aliasing -fwrapv', the run-time
results of the following combinations:
-O0 -m64: 0 0
-O1 -m64: 0 0
-O2 -m64: 0 0
-O3 -m64: 0 0
-O0 -m32: 0 0
-O1 -m32: 0 0
-O2 -m32: 0 0
-O3 -m32: 0 0
-O0 -mx32: 0 0
-O1 -mx32: -1 22 // munmap failed, EINVAL
-O2 -mx32: -1 22
-O3 -mx32: -1 22
A failure is not observed when:
- The condition is: if (b.ptr && b.length)
- The condition is: if (b.length)
- The ptr and length fields in Array are swapped.
- Array is passed by reference.
Tested with 8.4.0, 9.2.0, and 10.0.1. All have the same problem.