[PATCH] libstdc++: Define P0952 generate_canonical in inline namespace.
Tomasz Kaminski
tkaminsk@redhat.com
Wed Dec 17 12:46:59 GMT 2025
On Wed, Dec 17, 2025 at 1:41 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> On Wed, 17 Dec 2025 at 12:38, Jonathan Wakely <jwakely@redhat.com> wrote:
> >
> > On Wed, 17 Dec 2025 at 10:34, Tomasz Kamiński <tkaminsk@redhat.com>
> wrote:
> > >
> > > Defining the new implementation inside the _V2 inline namespace,
> > > would guaranteed TUs using old definition (GCC-15 or ones defining
> > > _GLIBCXX_USE_OLD_GENERATE_CANONICAL) will observe old behavior
> > > (call old implementation) when linked against TUs using new
> > > implementation.
> > >
> > > This updates random/pr60037-neg.cc to accept static assertion
> > > with a given message on any line number. Preventing need for
> > > constant updates.
> > >
> > > libstdc++-v3/ChangeLog:
> > >
> > > * include/bits/random.h (generate_canonical)
> > > [!_GLIBCXX_USE_OLD_GENERATE_CANONICAL]: Define inside
> > > _V2 inline namespace.
> > > * include/bits/random.tcc (generate_canonical)
> > > [!_GLIBCXX_USE_OLD_GENERATE_CANONICAL]: Likewise.
> > > * testsuite/26_numerics/random/pr60037-neg.cc: Make
> > > test independed on line of which static assert is placed.
> >
> > "independent of line on which"
>
> FWIW, I used this commit msg in my local commit. The extra text about
> the change to the test might be worth using ... but on the other hand
> it's a lot of words for a tiny change to one test!
>
> libstdc++: Move new std::generate_canonical to inline namespace
>
> This ensures that the new definition of std::generate_canonical has a
> different mangled name from the old one, so that TUs compiled with GCC
> 16 will be sure to use the new definition, even if the linker also sees
> a symbol instantiated from the old definition. We use the same _V2
> inline namespace as used elsewhere (std::_V2::condition_variable,
> std::_V2::__rotate, and std::chrono::_V2::system_clock), and use a macro
> to add it conditionally so that it's not used for the ABI-unstable
> gnu-versioned-namespace configuration.
>
This is much nicer description, and will be useful for someone who will
wonder
why _V2 was used, so I would suggest that you post your local change.
>
> We can simplify the 26_numerics/random/pr60037-neg.cc test to only use
> one dg-error without a line number, so that it matches any of the three
> relevant static_assert failures for this test: the one from _Adaptor in
> <bits/random.h> and the ones from the new and old definitions of
> std::generate_canonical in <bits/random.tcc>. Without this change, the
> line number for the dg-error matching the <bits/random.tcc> error epends
> on the _GLIBCXX_USE_OLD_GENERATE_CANONICAL macro, which is awkward to
> depend on in the test (because DejaGnu sees all dg-error directives, it
> doesn't care if they're guarded by #ifdef preprocessor checks).
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/random.h [!_GLIBCXX_USE_OLD_GENERATE_CANONICAL]
> (generate_canonical): Use inline namespace _V2.
> * include/bits/random.tcc [!_GLIBCXX_USE_OLD_GENERATE_CANONICAL]
> (generate_canonical): Likewise.
> * testsuite/26_numerics/random/pr60037-neg.cc: Remove lineno so
> that one dg-error matches both diagnostics.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20251217/0983b476/attachment.htm>
More information about the Libstdc++
mailing list