On Tue, 3 Feb 2026 at 15:19, Jonathan Wakely <[email protected]> wrote:
>
> On Tue, 3 Feb 2026 at 15:10, Jonathan Wakely <[email protected]> wrote:
> >
> > On Tue, 3 Feb 2026 at 15:04, Stephan Bergmann <[email protected]> wrote:
> > >
> > > On 1/27/26 01:33, Iain Sandoe wrote:
> > > > From: Nina Ranns <[email protected]>
> > > >
> > > > Changes since v3
> > > >
> > > >   - rebased onto r16-7033-gfb6a2e3f1fa842 (includes reflection changes).
> > > >
> > > > Changes since v2
> > > >
> > > >   - rebased onto r16-6757-g460edeb8bea11e (includes new year (c) 
> > > > change).
> > > >
> > > > Changes since v1
> > > >   - addressed Jonathan's review comments
> > > >   - fixed a merge error in the removal of C++2a code.
> > > >   - rebased onto r16-5785-g3b30d09ac7bbf8 (includes change to default to
> > > >     C++20).
> > >
> > > This started to cause
> > >
> > > > $ cat test.cc
> > > > #include <source_location>
> > > > struct S { S(char const *); };
> > > > void f(S);
> > > > void f(std::source_location);
> > > > int main() { f(""); }
> > >
> > > to fail
> > >
> > > > $ g++ -std=c++20 -fsyntax-only test.cc
> > > > test.cc: In function ‘int main()’:
> > > > test.cc:5:15: error: call of overloaded ‘f(const char [1])’ is ambiguous
> > > >     5 | int main() { f(""); }
> > > >       |              ~^~~~
> > > >   • there are 2 candidates
> > > >     • candidate 1: ‘void f(S)’
> > > >       test.cc:3:6:
> > > >           3 | void f(S);
> > > >             |      ^
> > > >     • candidate 2: ‘void f(std::source_location)’
> > > >       test.cc:4:6:
> > > >           4 | void f(std::source_location);
> > > >             |      ^
> > >
> > > which I assume is unintended?
> >
> > I don't understand why,
>
> Oh right, it's because the new constructor is defined unconditionally,
> rather than only when contracts are enabled. Making that constructor
> depend on -fcontracts wouldn't help, because the problem would still
> exist with -fcontracts.
>
> Making it explicit is better anyway, even if it wasn't needed to fix this.

This should be fixed with  r16-7338-g269ce3de8c49c2


Thanks for reporting it.

>
>
> > but we can fix it like this:
> >
> > --- a/libstdc++-v3/include/std/source_location
> > +++ b/libstdc++-v3/include/std/source_location
> > @@ -89,7 +89,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >   private:
> >     const __impl* _M_impl = nullptr;
> >
> > -    constexpr source_location (const void *__t)
> > +    constexpr explicit source_location (const void *__t)
> >       : _M_impl (static_cast <const __impl*>(__t)) {}
> >
> > #ifdef __glibcxx_contracts

Reply via email to