Closed
Description
Bugzilla Link | 47792 |
Version | trunk |
OS | All |
CC | @hubert-reinterpretcast,@zygoloid |
Extended Description
Consider the following program:
#include
#include <type_traits>
template<decltype(auto) N>
void f()
{
std::cout << std::is_same_v<decltype(N), int> << std::endl;
}
int main()
{
const int i = 0;
f<i>();
decltype(auto) N = i;
std::cout << std::is_same_v<decltype(N), const int> << std::endl;
}
When compiling it with -std=c++17 -pedantic-errors and the running it the following is outputed:
1
1
This means that the two decltype(auto) deductions behaved differently since they deduced different types ( N = int and N = const int ). I expect them to behave the same way.
Note that gcc gives the expected result ( N = const int for both deductions ).
Link to compiler explorer (clang to the left, gcc to the right):