https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99895
Bug ID: 99895 Summary: Function parameters generated wrong in call to member of non-type template parameter in lambda Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bisqwit at iki dot fi Target Milestone: --- GCC produces false error message: bug1.cc: In instantiation of ‘consteval void VerifyHash() [with unsigned int expected_hash = 5; fixed_string<...auto...> ...s = {fixed_string<6>{"khaki"}, fixed_string<6>{"plums"}}]’: bug1.cc:24:37: required from here bug1.cc:19:41: error: no matching function for call to ‘fixed_string<6>::data(const fixed_string<6>*)’ 19 | [](auto){static_assert(hash(s.data(), s.size()) == expected_hash);}(s) | ~~~~~~^~ bug1.cc:11:27: note: candidate: ‘consteval const char* fixed_string<N>::data() const [with long unsigned int N = 6]’ 11 | consteval const char* data() const { return str; } | ^~~~ bug1.cc:11:27: note: candidate expects 0 arguments, 1 provided On this code: #include <algorithm> // copy_n and size_t static constexpr unsigned hash(const char* s, std::size_t length) { s=s; return length; } template<std::size_t N> struct fixed_string { constexpr fixed_string(const char (&s)[N]) { std::copy_n(s, N, str); } consteval const char* data() const { return str; } consteval std::size_t size() const { return N-1; } char str[N]; }; template<unsigned expected_hash, fixed_string... s> static consteval void VerifyHash() { ( [](auto){static_assert(hash(s.data(), s.size()) == expected_hash);}(s) ,...); // The compiler mistakenly translates s.data() into s.data(&s) // and then complains that the call is not valid, because // the function expects 0 parameters and 1 "was provided". } void foo() { VerifyHash<5, "khaki", "plums">(); } Compiler version: g++-10 (Debian 10.2.1-6) 10.2.1 20210110