[Bug target/94383] New: [8/9/10 Regression] class with empty base passed incorrectly with -std=c++17
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Mar 28 15:54:10 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94383
Bug ID: 94383
Summary: [8/9/10 Regression] class with empty base passed
incorrectly with -std=c++17
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: ABI
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
Target: aarch64-*-linux
This code is miscompiled on aarch64 with -std=c++17, apparently due to the
empty base class:
struct base { };
struct pair : base
{
float first;
float second;
pair(float f, float s) : first(f), second(s) { }
};
void f(pair);
int main()
{
f({3.14, 666});
}
It is wrong with any optimization level, but with -std=gnu++14 -O1 we get:
main:
stp x29, x30, [sp, -16]!
mov x29, sp
mov x0, 0
mov x1, 62915
movk x1, 0x4048, lsl 16
bfi x0, x1, 0, 32
mov x1, 32768
movk x1, 0x4426, lsl 16
bfi x0, x1, 32, 32
lsr w1, w0, 0
fmov d0, x0
ushr d1, d0, 32
fmov s0, w1
bl f(pair)
mov w0, 0
ldp x29, x30, [sp], 16
ret
With -std=gnu++17 -O1 we get:
main:
stp x29, x30, [sp, -16]!
mov x29, sp
mov x0, 0
mov x1, 62915
movk x1, 0x4048, lsl 16
bfi x0, x1, 0, 32
mov x1, 32768
movk x1, 0x4426, lsl 16
bfi x0, x1, 32, 32
bl f(pair)
mov w0, 0
ldp x29, x30, [sp], 16
ret
If the translation unit containing the called function is:
struct base { };
struct pair : base
{
float first;
float second;
pair(float f, float s) : first(f), second(s) { }
};
void f(pair lr)
{
__builtin_printf("%f %f\n", lr.first, lr.second);
}
and the caller is compiled with -std=gnu++14 and the callee is compiled with
-std=gnu++17 then the callee prints garabage:
-13874.335938 0.000000
More information about the Gcc-bugs
mailing list