Open
Description
Title: UFCS with variable template in scope fails.
Description:
std::vector<int>().empty()
will fail given using std::views::empty;
.
That should end up calling the member empty
of std::vector
.
But the UFCS macro fails on the free function branch.
All compilers fail: https://compiler-explorer.com/z/bWejqfodq.
With #506, MSVC starts accepting: https://compiler-explorer.com/z/TYaMW7av6.
Minimal reproducer (https://cpp2.godbolt.org/z/7nfzr7zYx):
#include <ranges>
#include <vector>
using std::views::empty;
auto _ = std::vector<int>().empty();
main: () = {
_ = std::vector<int>().empty();
}
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp
Expected result: A well-formed program that calls the member empty
of std::vector
.
Actual result and error:
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
//=== Cpp2 type definitions and function declarations ===========================
#include <ranges>
#include <vector>
using std::views::empty;
auto _ = std::vector<int>().empty();
auto main() -> int;
//=== Cpp2 function definitions =================================================
auto main() -> int{
static_cast<void>(CPP2_UFCS_0(empty, std::vector<int>()));
}
Output:
main.cpp2:6:33: error: use of variable template 'empty' requires template arguments
6 | static_cast<void>(CPP2_UFCS_0(empty, std::vector<int>()));
| ^
/opt/compiler-explorer/clang-trunk-20231104/bin/../include/c++/v1/__ranges/empty_view.h:45:36: note: template is declared here
44 | template <class _Tp>
| ~~~~~~~~~~~~~~~~~~~~
45 | inline constexpr empty_view<_Tp> empty{};
| ^
1 error generated.