https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116148
Kewen Lin <linkw at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 CC| |linkw at gcc dot gnu.org Status|UNCONFIRMED |NEW Last reconfirmed| |2024-07-31 --- Comment #3 from Kewen Lin <linkw at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #2) > (In reply to Andrew Pinski from comment #1) > > This testcase was only designed for little-endian ... > > That is it needs some changes to the checks to allow to run correctly on > big-endian. Indeed, the below adjustment makes it pass on BE. diff --git a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c index 93f9d5128f6..7845a7fbab3 100644 --- a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c +++ b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-2.c @@ -16,7 +16,7 @@ union with_fam_2 { union with_fam_3 { char a[]; int b[]; -} with_fam_3_v = {.b = {0x1f2f3f4f, 0x5f6f7f7f}}; +} with_fam_3_v = {.b = {0x1f2f3f4f, 0x5f6f7f8f}}; struct only_fam { int b[]; @@ -28,16 +28,28 @@ struct only_fam_2 { int b[]; } only_fam_2_v = {{7, 11}}; +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define WITH_FAM_2_V_B0 0x4f +#define WITH_FAM_2_V_B3 0x1f +#define WITH_FAM_3_V_A0 0x4f +#define WITH_FAM_3_V_A7 0x5f +#else +#define WITH_FAM_2_V_B0 0x1f +#define WITH_FAM_2_V_B3 0x4f +#define WITH_FAM_3_V_A0 0x1f +#define WITH_FAM_3_V_A7 0x8f +#endif + int main () { if (with_fam_1_v.b[3] != 4 || with_fam_1_v.b[0] != 1) __builtin_abort (); - if (with_fam_2_v.b[3] != 0x1f - || with_fam_2_v.b[0] != 0x4f) + if (with_fam_2_v.b[3] != WITH_FAM_2_V_B3 + || with_fam_2_v.b[0] != WITH_FAM_2_V_B0) __builtin_abort (); - if (with_fam_3_v.a[0] != 0x4f - || with_fam_3_v.a[7] != 0x5f) + if (with_fam_3_v.a[0] != WITH_FAM_3_V_A0 + || with_fam_3_v.a[7] != WITH_FAM_3_V_A7) __builtin_abort (); if (only_fam_v.b[0] != 7 || only_fam_v.b[1] != 11)