Thanks to visit codestin.com
Credit goes to github.com

Skip to content

<algorithm>: unqualified calls to _Adl_verify_range incorrectly cause instantiation #1596

@CaseyCarter

Description

@CaseyCarter

Our implementation rejects this well-formed program (derived from the libc++ test that fails because of this bug):

#include <algorithm>
#include <iterator>

struct incomplete;

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

int main() {
    wrapper<incomplete>* some_pointers[42]{};
    std::sort(std::begin(some_pointers), std::end(some_pointers));
}

by trying to instantiate wrapper<incomplete> despite that such instantiation is not necessary. The unqualified call to _Adl_verify_range(_First, _Last) (which appears in most algorithms, std::sort is simply an exemplar) necessitates instantiation of wrapper<incomplete> when _First has type wrapper<incomplete>**.

The problem runs deeper than simply _STD-qualifying _Adl_verify_range:

  • the machinery it uses presumably makes other unqualified calls that will need to be dealt with, and
  • the unqualified call to _Verify_range should be avoided when the arguments are pointers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions