On Wed, Apr 22, 2026 at 1:46 PM Jonathan Wakely <[email protected]> wrote:
> On Wed, 22 Apr 2026 at 12:39, Tomasz Kamiński <[email protected]> wrote: > > > > This implements LWG4290. Missing Mandates clauses on > is_sufficiently_aligned. > > > > libstdc++-v3/ChangeLog: > > > > * include/bits/align.h (is_sufficiently_aligned): Mandate > > that _Align is power of two. > > * testsuite/std/time/format/simple.cc: New test. > > Did you 'git add' the wrong test? > Yes, will post v2 soon. > > > --- > > No adding resolve issue comment, as this is C++26 feature. > > > > Tested on x86_64-linux. OK for trunk? > > > > libstdc++-v3/include/bits/align.h | 5 ++++- > > libstdc++-v3/testsuite/std/time/format/simple.cc | 11 +++++++++++ > > 2 files changed, 15 insertions(+), 1 deletion(-) > > create mode 100644 libstdc++-v3/testsuite/std/time/format/simple.cc > > > > diff --git a/libstdc++-v3/include/bits/align.h > b/libstdc++-v3/include/bits/align.h > > index 1a14e282216..3c8355d0e07 100644 > > --- a/libstdc++-v3/include/bits/align.h > > +++ b/libstdc++-v3/include/bits/align.h > > @@ -116,7 +116,10 @@ align(size_t __align, size_t __size, void*& __ptr, > size_t& __space) noexcept > > [[nodiscard,__gnu__::__always_inline__]] > > inline bool > > is_sufficiently_aligned(_Tp* __ptr) > > - { return reinterpret_cast<__UINTPTR_TYPE__>(__ptr) % _Align == 0; } > > + { > > + static_assert(std::has_single_bit(_Align)); > > + return reinterpret_cast<__UINTPTR_TYPE__>(__ptr) % _Align == 0; > > + } > > #endif // __glibcxx_is_sufficiently_aligned > > > > _GLIBCXX_END_NAMESPACE_VERSION > > diff --git a/libstdc++-v3/testsuite/std/time/format/simple.cc > b/libstdc++-v3/testsuite/std/time/format/simple.cc > > new file mode 100644 > > index 00000000000..db25a460bf7 > > --- /dev/null > > +++ b/libstdc++-v3/testsuite/std/time/format/simple.cc > > @@ -0,0 +1,11 @@ > > +// { dg-do run { target c++20 } } > > +// { dg-timeout-factor 2 } > > + > > +#include <chrono> > > +#include <vector> > > +#include <testsuite_hooks.h> > > + > > +int main() > > +{ > > + auto s = std::format("{:%F %T}", std::chrono::system_clock::now()); > > +} > > -- > > 2.53.0 > > > >
