C++ Logo

std-discussion

Advanced search

using declaration. template default argument. One more bug of gcc?

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Fri, 23 Aug 2019 18:35:21 +0300
It seems that gcc HEAD 10.0.0 20190 has one more bug relative to the using declaration.
The following program does not compile.
#include<iostream>

void g(int x )
{
    std::cout <<"Hello g( "<< x <<" )\n";
}

template<int N>void g()
{
    std::cout <<"Hello g<N>( "<< N <<" )\n";
}
namespace N
{
   using::g;
}

void g(int x =20);

template<int N =10>
void g();

int main()
{
    N::g();
    N::g<>();
}
The compiler issues the error
prog.cc:Infunction'int main()':
prog.cc:27:11: error:no matching functionfor call to 'g()'27| N::g<>();|^
prog.cc:9:6: note: candidate:'template<int N> void g()'9|void g()|^
prog.cc:9:6: note:template argument deduction/substitution failed:
prog.cc:27:11: note: couldn't deduce template parameter 'N'
   27 | N::g<>();
      | ^
though according to the C++ 20 (and 17) Standard (9.8 The using declaration)
>11 [Note: For a using-declaration whose nested-name-specifier names a namespace, members added to the namespace after the using-declaration are not in the set of introduced declarations, so they are not considered when a use of the name is made. Thus, additional overloads added after the using-declaration are ignored, but default function arguments (9.2.3.6), default template arguments (13.1), and template specializations (13.6.5, 13.8.3) are considered . — end note]
With best regards,
Vlad from Moscow

You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

Received on 2019-08-23 10:37:27