public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++ testsuite: Correct S0 in std/time/hh_mm_ss/1.cc
@ 2023-02-01 14:38 Hans-Peter Nilsson
  2023-02-01 16:01 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Hans-Peter Nilsson @ 2023-02-01 14:38 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Tested cris-elf and native x86_64-pc-linux-gnu.
Ok to commit?

-----8< ------

For targets where the ABI mandates structure layout that has
no padding, like cris-elf, this test started failing when
introduced as an add-on to the existing 1.cc, thereby
effectively causing a regression in testsuite results.
Adding an empty structure to S0, corresponds better to the
layout of hh_mm_ss<seconds>.

	PR testsuite/108632
	* testsuite/std/time/hh_mm_ss/1.cc (size): Add empty
	struct at end of S0.
---
 libstdc++-v3/testsuite/std/time/hh_mm_ss/1.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/std/time/hh_mm_ss/1.cc b/libstdc++-v3/testsuite/std/time/hh_mm_ss/1.cc
index d97a9057f472..26a4555576c8 100644
--- a/libstdc++-v3/testsuite/std/time/hh_mm_ss/1.cc
+++ b/libstdc++-v3/testsuite/std/time/hh_mm_ss/1.cc
@@ -103,7 +103,7 @@ size()
 {
   using namespace std::chrono;
 
-  struct S0 { long long h; char m; char s; bool neg; };
+  struct S0 { long long h; char m; char s; bool neg; struct { } empty; };
   static_assert(sizeof(hh_mm_ss<seconds>) == sizeof(S0));
   struct S1 { long long h; char m; char s; bool neg; char ss; };
   static_assert(sizeof(hh_mm_ss<duration<int, std::centi>>) == sizeof(S1));
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libstdc++ testsuite: Correct S0 in std/time/hh_mm_ss/1.cc
  2023-02-01 14:38 [PATCH] libstdc++ testsuite: Correct S0 in std/time/hh_mm_ss/1.cc Hans-Peter Nilsson
@ 2023-02-01 16:01 ` Jonathan Wakely
  2023-02-01 17:19   ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2023-02-01 16:01 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: libstdc++, gcc-patches

On Wed, 1 Feb 2023 at 14:38, Hans-Peter Nilsson via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Tested cris-elf and native x86_64-pc-linux-gnu.
> Ok to commit?

OK, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libstdc++ testsuite: Correct S0 in std/time/hh_mm_ss/1.cc
  2023-02-01 16:01 ` Jonathan Wakely
@ 2023-02-01 17:19   ` Jonathan Wakely
  2023-02-01 22:37     ` Hans-Peter Nilsson
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2023-02-01 17:19 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: libstdc++, gcc-patches

On Wed, 1 Feb 2023 at 16:01, Jonathan Wakely wrote:
>
> On Wed, 1 Feb 2023 at 14:38, Hans-Peter Nilsson via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > Tested cris-elf and native x86_64-pc-linux-gnu.
> > Ok to commit?
>
> OK, thanks.

We could add the [[no_unique_address]] attribute to the _M_ss member,
so that it takes no space when it's an empty struct.

That would save a byte in hh_mm_ss for cris-elf and targets like that,
but as this type isn't meant to be used for storage, I don't think we
should bother. People shouldn't be using this as a data member, just
creating it on the stack and then discarding it.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libstdc++ testsuite: Correct S0 in std/time/hh_mm_ss/1.cc
  2023-02-01 17:19   ` Jonathan Wakely
@ 2023-02-01 22:37     ` Hans-Peter Nilsson
  0 siblings, 0 replies; 4+ messages in thread
From: Hans-Peter Nilsson @ 2023-02-01 22:37 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

> From: Jonathan Wakely <jwakely@redhat.com>
> Date: Wed, 1 Feb 2023 18:19:09 +0100

> On Wed, 1 Feb 2023 at 16:01, Jonathan Wakely wrote:
> >
> > On Wed, 1 Feb 2023 at 14:38, Hans-Peter Nilsson via Libstdc++
> > <libstdc++@gcc.gnu.org> wrote:
> > >
> > > Tested cris-elf and native x86_64-pc-linux-gnu.
> > > Ok to commit?
> >
> > OK, thanks.
> 
> We could add the [[no_unique_address]] attribute to the _M_ss member,
> so that it takes no space when it's an empty struct.
> 
> That would save a byte in hh_mm_ss for cris-elf and targets like that,
> but as this type isn't meant to be used for storage, I don't think we
> should bother. People shouldn't be using this as a data member, just
> creating it on the stack and then discarding it.
> 

Agreed; no worries.  Thanks for the review.

brgds, H-P

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-01 22:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-01 14:38 [PATCH] libstdc++ testsuite: Correct S0 in std/time/hh_mm_ss/1.cc Hans-Peter Nilsson
2023-02-01 16:01 ` Jonathan Wakely
2023-02-01 17:19   ` Jonathan Wakely
2023-02-01 22:37     ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).