Skip to content

[clang 16 & trunk][c++20] Crash when mixing iterator concepts, ADL and using-declarations in a requires expression #63808

@octurion

Description

@octurion

After drawing some inspiration from this StackOverflow answer, I decided to write up the following code that checks the presence of begin() and end() via ADL:

#include <concepts>
#include <iterator>
#include <vector>

template <typename T>
concept HasBeginEnd = []{
    using std::begin;
    using std::end;

    return requires(T& t)
    {
        {begin(t)} -> std::input_iterator;
        {end(t)} -> std::input_iterator;
    };
}();
static_assert(HasBeginEnd<std::vector<int>>);

This, however, crashes Clang 16 and trunk on Godbolt. Surprisingly, it appears that Clang 15 and older are not affected.

Godbolt link: https://godbolt.org/z/zndsGP63Y

Stacktrace generated: stacktrace.txt

Metadata

Metadata

Assignees

Labels

c++20clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsconfirmedVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions