https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92766
Bug ID: 92766
Summary: [Rejects valid] pointer+0 erroneously treated as
rvalue
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: bisqwit at iki dot fi
Target Milestone: ---
template<typename T>
void foo(T&& begin, T&& end);
void test()
{
unsigned char buffer[16];
const unsigned char* ptr = buffer;
foo(ptr+0, ptr+8);
}
On GCC 8.3, this compiles fine.
On GCC 9.1 and trunk, fails to compile (-std=c++11, c++14, c++17, c++2a):
<source>:8:21: error: no matching function for call to 'foo(const unsigned
char*&, const unsigned char*)'
8 | foo(ptr+0, ptr+8);
| ^
<source>:2:6: note: candidate: 'template<class T> void foo(T&&, T&&)'
2 | void foo(T&& begin, T&& end);
| ^~~
<source>:2:6: note: template argument deduction/substitution failed:
<source>:8:21: note: deduced conflicting types for parameter 'T' ('const
unsigned char*&' and 'const unsigned char*')
8 | foo(ptr+0, ptr+8);
| ^
Compiler returned: 1