testsuite: Fix struct size check [PR116155]
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
Commit Message
The size of "struct only_fam_2" is dependent on the alignment of the
flexible array member "b", and not on the type of the preceding
bit-fields. For most targets the two are equal. But on default_packed
targets like pru-unknown-elf, the alignment of int is not equal to the
size of int, so the test failed.
Patch was suggested by Qing Zhao. Tested on pru-unknown-elf and
x86_64-pc-linux-gnu.
Ok for master?
PR testsuite/116155
gcc/testsuite/ChangeLog:
* c-c++-common/fam-in-union-alone-in-struct-1.c: Adjust
check to account for default_packed targets.
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
---
gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
I stumbled on this being a regression for cris-elf as well;
the patch expectedly fixes the test-case for CRIS as well.
It's been a week since the patch was posted and as I see no
replies, I'm pinging this in behalf of Dimitar.
> From: Dimitar Dimitrov <dimitar@dinux.eu>
> Date: Mon, 5 Aug 2024 21:29:35 +0300
> The size of "struct only_fam_2" is dependent on the alignment of the
> flexible array member "b", and not on the type of the preceding
> bit-fields. For most targets the two are equal. But on default_packed
> targets like pru-unknown-elf, the alignment of int is not equal to the
> size of int, so the test failed.
>
> Patch was suggested by Qing Zhao. Tested on pru-unknown-elf and
> x86_64-pc-linux-gnu.
>
> Ok for master?
>
> PR testsuite/116155
>
> gcc/testsuite/ChangeLog:
>
> * c-c++-common/fam-in-union-alone-in-struct-1.c: Adjust
> check to account for default_packed targets.
>
> Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
> ---
> gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c
> index 39ebf17850b..9979e96fe70 100644
> --- a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c
> +++ b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c
> @@ -45,7 +45,7 @@ int main ()
> __builtin_abort ();
> if (sizeof (struct only_fam) != 0)
> __builtin_abort ();
> - if (sizeof (struct only_fam_2) != sizeof (int))
> + if (sizeof (struct only_fam_2) != __alignof__ (int))
> __builtin_abort ();
> return 0;
> }
> --
> 2.45.2
>
Hans-Peter Nilsson <hp@axis.com> writes:
> I stumbled on this being a regression for cris-elf as well;
> the patch expectedly fixes the test-case for CRIS as well.
> It's been a week since the patch was posted and as I see no
> replies, I'm pinging this in behalf of Dimitar.
I can't formally approve it but I think we should commit it. it's
obviously right, the test author suggested it, and it wasn't being run
until recently (i.e. we fully understand why this is only appearing
now).
thanks.
>
>> From: Dimitar Dimitrov <dimitar@dinux.eu>
>> Date: Mon, 5 Aug 2024 21:29:35 +0300
>
>> The size of "struct only_fam_2" is dependent on the alignment of the
>> flexible array member "b", and not on the type of the preceding
>> bit-fields. For most targets the two are equal. But on default_packed
>> targets like pru-unknown-elf, the alignment of int is not equal to the
>> size of int, so the test failed.
>>
>> Patch was suggested by Qing Zhao. Tested on pru-unknown-elf and
>> x86_64-pc-linux-gnu.
>>
>> Ok for master?
>>
>> PR testsuite/116155
>>
>> gcc/testsuite/ChangeLog:
>>
>> * c-c++-common/fam-in-union-alone-in-struct-1.c: Adjust
>> check to account for default_packed targets.
>>
>> Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
>> ---
>> gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c
>> index 39ebf17850b..9979e96fe70 100644
>> --- a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c
>> +++ b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c
>> @@ -45,7 +45,7 @@ int main ()
>> __builtin_abort ();
>> if (sizeof (struct only_fam) != 0)
>> __builtin_abort ();
>> - if (sizeof (struct only_fam_2) != sizeof (int))
>> + if (sizeof (struct only_fam_2) != __alignof__ (int))
>> __builtin_abort ();
>> return 0;
>> }
>> --
>> 2.45.2
>>
> From: Sam James <sam@gentoo.org>
> Date: Tue, 13 Aug 2024 18:17:29 +0100
> Hans-Peter Nilsson <hp@axis.com> writes:
>
> > I stumbled on this being a regression for cris-elf as well;
> > the patch expectedly fixes the test-case for CRIS as well.
> > It's been a week since the patch was posted and as I see no
> > replies, I'm pinging this in behalf of Dimitar.
>
> I can't formally approve it but I think we should commit it. it's
> obviously right, the test author suggested it, and it wasn't being run
> until recently (i.e. we fully understand why this is only appearing
> now).
Oh! I see it was part of that dg- fixup! Yes, agreed:
given the history I'll commit it as obvious later today.
I don't mind if someone beats me to the punch. Thanks.
brgds, H-P
>
> thanks.
>
> >
> >> From: Dimitar Dimitrov <dimitar@dinux.eu>
> >> Date: Mon, 5 Aug 2024 21:29:35 +0300
> >
> >> The size of "struct only_fam_2" is dependent on the alignment of the
> >> flexible array member "b", and not on the type of the preceding
> >> bit-fields. For most targets the two are equal. But on default_packed
> >> targets like pru-unknown-elf, the alignment of int is not equal to the
> >> size of int, so the test failed.
> >>
> >> Patch was suggested by Qing Zhao. Tested on pru-unknown-elf and
> >> x86_64-pc-linux-gnu.
> >>
> >> Ok for master?
> >>
> >> PR testsuite/116155
> >>
> >> gcc/testsuite/ChangeLog:
> >>
> >> * c-c++-common/fam-in-union-alone-in-struct-1.c: Adjust
> >> check to account for default_packed targets.
> >>
> >> Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
> >> ---
> >> gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c
> >> index 39ebf17850b..9979e96fe70 100644
> >> --- a/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c
> >> +++ b/gcc/testsuite/c-c++-common/fam-in-union-alone-in-struct-1.c
> >> @@ -45,7 +45,7 @@ int main ()
> >> __builtin_abort ();
> >> if (sizeof (struct only_fam) != 0)
> >> __builtin_abort ();
> >> - if (sizeof (struct only_fam_2) != sizeof (int))
> >> + if (sizeof (struct only_fam_2) != __alignof__ (int))
> >> __builtin_abort ();
> >> return 0;
> >> }
> >> --
> >> 2.45.2
> >>
>
Hans-Peter Nilsson <hp@axis.com> writes:
>> From: Sam James <sam@gentoo.org>
>> Date: Tue, 13 Aug 2024 18:17:29 +0100
>
>> Hans-Peter Nilsson <hp@axis.com> writes:
>>
>> > I stumbled on this being a regression for cris-elf as well;
>> > the patch expectedly fixes the test-case for CRIS as well.
>> > It's been a week since the patch was posted and as I see no
>> > replies, I'm pinging this in behalf of Dimitar.
>>
>> I can't formally approve it but I think we should commit it. it's
>> obviously right, the test author suggested it, and it wasn't being run
>> until recently (i.e. we fully understand why this is only appearing
>> now).
>
> Oh! I see it was part of that dg- fixup! Yes, agreed:
> given the history I'll commit it as obvious later today.
> I don't mind if someone beats me to the punch. Thanks.
>
Thanks! I'll have more of those soon, but I wanted to let things settle
down a bit first (trying to keep a close eye on any bugs and
gcc-testresults mails for regressions).
best,
sam
> [...]
On Tue, Aug 13, 2024 at 07:34:09PM +0200, Hans-Peter Nilsson wrote:
> > From: Sam James <sam@gentoo.org>
> > Date: Tue, 13 Aug 2024 18:17:29 +0100
>
> > Hans-Peter Nilsson <hp@axis.com> writes:
> >
> > > I stumbled on this being a regression for cris-elf as well;
> > > the patch expectedly fixes the test-case for CRIS as well.
> > > It's been a week since the patch was posted and as I see no
> > > replies, I'm pinging this in behalf of Dimitar.
> >
> > I can't formally approve it but I think we should commit it. it's
> > obviously right, the test author suggested it, and it wasn't being run
> > until recently (i.e. we fully understand why this is only appearing
> > now).
>
> Oh! I see it was part of that dg- fixup! Yes, agreed:
> given the history I'll commit it as obvious later today.
> I don't mind if someone beats me to the punch. Thanks.
I committed it. Thanks.
Dimitar
>
> brgds, H-P
>
> On Aug 13, 2024, at 17:05, Dimitar Dimitrov <dimitar@dinux.eu> wrote:
>
> On Tue, Aug 13, 2024 at 07:34:09PM +0200, Hans-Peter Nilsson wrote:
>>> From: Sam James <sam@gentoo.org>
>>> Date: Tue, 13 Aug 2024 18:17:29 +0100
>>
>>> Hans-Peter Nilsson <hp@axis.com> writes:
>>>
>>>> I stumbled on this being a regression for cris-elf as well;
>>>> the patch expectedly fixes the test-case for CRIS as well.
>>>> It's been a week since the patch was posted and as I see no
>>>> replies, I'm pinging this in behalf of Dimitar.
>>>
>>> I can't formally approve it but I think we should commit it. it's
>>> obviously right, the test author suggested it, and it wasn't being run
>>> until recently (i.e. we fully understand why this is only appearing
>>> now).
>>
>> Oh! I see it was part of that dg- fixup! Yes, agreed:
>> given the history I'll commit it as obvious later today.
>> I don't mind if someone beats me to the punch. Thanks.
>
> I committed it. Thanks.
Thank you for fixing this.
Qing
>
> Dimitar
>>
>> brgds, H-P
@@ -45,7 +45,7 @@ int main ()
__builtin_abort ();
if (sizeof (struct only_fam) != 0)
__builtin_abort ();
- if (sizeof (struct only_fam_2) != sizeof (int))
+ if (sizeof (struct only_fam_2) != __alignof__ (int))
__builtin_abort ();
return 0;
}