Closed JohelEGP closed 6 months ago
A more realistic example (https://cpp2.godbolt.org/z/b4q6fK3nP):
algo: (copy r: std::string, copy size: int) = {
// ...
_ = r.size();
// ...
}
main: () = {}
With #887, I get (https://cpp1.godbolt.org/z/na3ejEGn7):
x.cpp2:3:21: error: no matching function for call to object of type '(lambda at x.cpp2:3:21)'
static_cast<void>(CPP2_UFCS(std::move(size))(std::move(r)));
^~~~~~~~~~~~~~~~~~~~~~~~~~
../root/include/cpp2util.h:854:59: note: expanded from macro 'CPP2_UFCS'
#define CPP2_UFCS(...) CPP2_UFCS_(&,(),,__VA_ARGS__)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../root/include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
^
x.cpp2:3:21: note: candidate template ignored: constraints not satisfied [with Obj = typename std::remove_reference<basic_string<char> &>::type, Params = <>]
../root/include/cpp2util.h:854:59: note: expanded from macro 'CPP2_UFCS'
#define CPP2_UFCS(...) CPP2_UFCS_(&,(),,__VA_ARGS__)
^
../root/include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
^
x.cpp2:3:36: note: because 'std::forward<decltype(obj)>(obj).std::move(size)(std::forward<decltype(params)>(params)...)' would be invalid: qualified member access refers to a member in namespace 'std'
static_cast<void>(CPP2_UFCS(std::move(size))(std::move(r)));
^
x.cpp2:3:31: note: and 'std::move(size)(std::forward<decltype(obj)>(obj), std::forward<decltype(params)>(params)...)' would be invalid: called object type 'typename std::remove_reference<int &>::type' (aka 'int') is not a function or function pointer
static_cast<void>(CPP2_UFCS(std::move(size))(std::move(r)));
^
1 error generated.
Title: Implicit move/forward interferes with main UFCS branch.
Description:
The semantics of
x.f()
are that ifx.f()
is well-formed, it is that, otherwise it isf(x)
.When
f
is a local subject to implicit move/forward, the insertedstd::
call makes the main branch never be taken.Currently, #832 prevents that from being tested.
Minimal reproducer (https://cpp2.godbolt.org/z/h14vYev4M):
Commands:
```bash cppfront main.cpp2 clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -Werror=unused-variable -I . main.cpp ```Expected result: The UFCS macro to consider
x.f()
instead ofx.std::move(f)
.Actual result and error:
Output:
See also:
832.