Issue 76366
Summary Wrong lookup handling in range-for loops
Labels new issue
Assignees
Reporter Fedr
    This program
```
#include <vector>

namespace ns {

template <typename T>
constexpr auto operator*(T&& /*value*/) {
    struct custom_type {};
    return custom_type{};
};

}  // namespace ns

template <typename T>
constexpr void foo() {
    std::vector<T> vec{};
    for (const auto& curr : vec) {
        static_assert(std::is_same_v<const T&, decltype(curr)>);
    }
}

int main() {
    using namespace ns;
    foo<int>();
}
```
is ok in GCC and MSVC, but fails in Clang:
```
error: static assertion failed due to requirement 'std::is_same_v<const int &, const custom_type &>'
```
Note `custom_type` type that cames from  `ns::operator*` and it should be impossible to find in `foo()` by any form of lookup.

Online demo: https://godbolt.org/z/qds8qo4cK

Related discussion: https://stackoverflow.com/q/77712202/7325599
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to