-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Candidate template ignored: invalid explicitly-specified argument for template parameter #42224
Comments
the selution: need to redefine the template for original template class: template<typename T> |
@llvm/issue-subscribers-clang-frontend |
Clang 16 fails to compile calls like "gather<Vector>()". c++ -O3 -pedantic -std=c++2a -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-address -frelaxed-template-template-args -Wno-ambiguous-reversed-operator -MD -MP -MF .command_manager.opt.d -c -o .command_manager.opt.o command_manager.cc command_manager.cc:825:104: error: no matching function for call to 'gather' auto params = tokens | skip(1) | transform(&Token::content) | filter(std::not_fn(is_switch)) | gather<Vector>(); ^~~~~~~~~~~~~~ ./ranges.hh:633:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Container' auto gather() ^ ./ranges.hh:642:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Container' auto gather() ^ 1 error generated. because Vector has a defaulted template argument but the argument to gather() has not. Upstream bug report: llvm/llvm-project#42224 (not sure why it worked for us with Clang 15). Work around this by adding gather() overloads whose template template parameter clang can match against Vector. Add another one for HashSet. GCC rejects calls to these overloads as ambiguous, so use conditional compilation. Fixes mawww#4872
Clang 16 fails to compile calls like "gather<Vector>()". c++ -O3 -pedantic -std=c++2a -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-address -frelaxed-template-template-args -Wno-ambiguous-reversed-operator -MD -MP -MF .command_manager.opt.d -c -o .command_manager.opt.o command_manager.cc command_manager.cc:825:104: error: no matching function for call to 'gather' auto params = tokens | skip(1) | transform(&Token::content) | filter(std::not_fn(is_switch)) | gather<Vector>(); ^~~~~~~~~~~~~~ ./ranges.hh:633:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Container' auto gather() ^ ./ranges.hh:642:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Container' auto gather() ^ 1 error generated. because Vector has a defaulted template argument but gather's formal parameter. Upstream bug report: llvm/llvm-project#42224 (not sure why it worked for us with Clang 15). Work around this by adding gather() overloads whose template template parameter clang can match against Vector. Add another one for HashSet. GCC rejects calls to these overloads as ambiguous, so use conditional compilation. Fixes mawww#4872
Clang 16 fails to compile calls like "gather<Vector>()". c++ -O3 -pedantic -std=c++2a -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-address -frelaxed-template-template-args -Wno-ambiguous-reversed-operator -MD -MP -MF .command_manager.opt.d -c -o .command_manager.opt.o command_manager.cc command_manager.cc:825:104: error: no matching function for call to 'gather' auto params = tokens | skip(1) | transform(&Token::content) | filter(std::not_fn(is_switch)) | gather<Vector>(); ^~~~~~~~~~~~~~ ./ranges.hh:633:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Container' auto gather() ^ ./ranges.hh:642:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Container' auto gather() ^ 1 error generated. because Vector has a defaulted template argument but gather's formal parameter. Upstream bug report: llvm/llvm-project#42224 (not sure why it worked for us with Clang 15). Work around this by adding gather() overloads whose template template parameter clang can match against Vector. Add another one for HashSet. GCC rejects calls to these overloads as ambiguous, so use conditional compilation. Fixes mawww#4872
…mplate template args Clang 16 fails to compile calls like "gather<Vector>()". c++ -O3 -pedantic -std=c++2a -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-address -frelaxed-template-template-args -Wno-ambiguous-reversed-operator -MD -MP -MF .command_manager.opt.d -c -o .command_manager.opt.o command_manager.cc command_manager.cc:825:104: error: no matching function for call to 'gather' auto params = tokens | skip(1) | transform(&Token::content) | filter(std::not_fn(is_switch)) | gather<Vector>(); ^~~~~~~~~~~~~~ ./ranges.hh:633:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Container' auto gather() ^ ./ranges.hh:642:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Container' auto gather() ^ 1 error generated. because Vector has a defaulted template argument but gather's formal parameter. Upstream bug report: llvm/llvm-project#42224 (not sure why it worked for us with Clang 15). Work around this by adding gather() overloads whose template template parameter clang can match against Vector. Add another one for HashSet. GCC rejects calls to these overloads as ambiguous, so use conditional compilation. Fixes mawww#4872
I found this one interesting: https://godbolt.org/z/P3fno44o1 The solution is to either match the template's parameter count or use a template pack:
|
Duplicate of #36505 |
@llvm/issue-subscribers-c-17 Author: Mikael Simonsson (msimonsson)
| | |
| --- | --- |
| Bugzilla Link | [42879](https://llvm.org/bz42879) |
| Version | trunk |
| OS | All |
| CC | @DougGregor,@zygoloid |
Extended DescriptionThe following code fails to compile with Clang but compiles with GCC (since 7.1). Clang wants a value for the defaulted template parameter Capacity. #include <cstddef>
template <typename T, size_t Capacity = 10>
class smallvector {
public:
smallvector(const T*, size_t);
};
template <typename T>
class span {
public:
span(const T*, size_t);
};
class str {
public:
str(const char* data, size_t size) : data_{data}, size_{size} {}
template <template <typename> typename Container>
Container<const char> to_container() {
return {data_, size_};
}
private:
const char* data_;
size_t size_;
};
void to_span(str& s) {
s.to_container<span>(); // This works.
}
void to_smallvector(str& s) {
s.to_container<smallvector>(); // This doesn't work.
} <source>:34:7: error: no matching member function for call to 'to_container'
s.to_container<smallvector>();
~~^~~~~~~~~~~~~~~~~~~~~~~~~
<source>:20:27: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Container'
Container<const char> to_container() {
^
1 error generated. Tested with clang version 10.0.0 (trunk 367740) and -std=c++17. |
Extended Description
The following code fails to compile with Clang but compiles with GCC (since 7.1). Clang wants a value for the defaulted template parameter Capacity.
Tested with clang version 10.0.0 (trunk 367740) and -std=c++17.
The text was updated successfully, but these errors were encountered: