Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<memory> etc.: ADL should be avoided when calling _Construct_in_place and its friends #3100

Open
frederick-vs-ja opened this issue Sep 14, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@frederick-vs-ja
Copy link
Contributor

frederick-vs-ja commented Sep 14, 2022

This well-formed program fails to compile with MSVC STL due to unqualified calls to internal functions (which trigger ADL and overly require completeness of related types).

#include <any>
#include <concepts>
#include <functional>
#include <memory>
#include <optional>
#include <variant>

struct Incomplete;

template<class T>
struct Holder {
    T t;
};

using Ptr = Holder<Incomplete>*;

int main()
{
    std::make_shared<Ptr>();
    std::make_shared<Ptr[]>(42);
    std::function<void(Ptr)>{std::identity{}};
    std::any{Ptr{}};
    std::optional<Ptr>{}.emplace();
    std::variant<Ptr>{}.emplace<Ptr>();
}

Godbolt link. (libc++ accepts it correctly)

This is similar to #1596 but touches different library mechanisms, and should be considered as a sub-issue of #140.
Previously, 3 libc++ tests were blocked by this issue:

  • std/utilities/function.objects/func.wrap/func.wrap.func/robust_against_adl.pass.cpp
  • std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
  • std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp

Perhaps we should _STD-qualify internal function calls used for in-place construction/destruction by default, especially for _Construct_in_place, _Destroy_in_place, and _Voidify_iter (_Voidify_iter was killed when implementing LWG-3870).

@frederick-vs-ja
Copy link
Contributor Author

frederick-vs-ja commented Mar 2, 2024

Remaining unqualified _Construct_in_place and _Destroy_in_place calls after #4430 are all in containers and valarray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants