[libcxx-commits] [libcxx] [libc++] LWG3223 Broken requirements for shared_ptr converting constructors (PR #93071)
Jonathan Wakely via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 12 03:45:54 PDT 2024
jwakely wrote:
> It was even there in C++11, and violating it led to undefined behaviour (rather than being ill-formed).
I'm wrong about this - it was fine in C++11, because we didn't try to test `d(p)` during overload resolution, so didn't get a hard error outside the immediate context. The problem is caused by checking the `d(p)` expression during overload resolution, when considering the `shared_ptr(nullptr_t, D)` ctor, which is never actually going to be selected for this call.
> I think for the two overloads taking `nullptr_t` the constraint should be that `d((T*)nullptr)` is well-formed, since that's what the implementation actually does.
And I was wrong about this too! As pointed out by Peter Dimov. The implementation really does do `d(nullptr)` if the `shared_ptr(nullptr_t, D)` constructor is called. But the problematic example above doesn't actually call that constructor, it just evaluates its constraints during overload resolution.
https://github.com/llvm/llvm-project/pull/93071
More information about the libcxx-commits
mailing list