jeudi 29 décembre 2016

Why does gcc hide overloaded functions in the global namespace?

void f() {}

namespace test
{
void f(int) {}    
void g() { f(); } // error in gcc 6.2.0
}

int main()
{
    test::g();
}

Compile it with g++ -std=c++1z main.cpp, the output is as follows:

main.cpp: In function 'void test::g()':
main.cpp:9:4: error: too few arguments to function 'void test::f(int)'
  f(); // error in gcc
    ^
main.cpp:5:6: note: declared here
 void f(int) {}

My compiler is gcc 6.2.0.

Why does gcc hide overloaded functions in the global namespace? Is this conforming to the C++ standard?

Aucun commentaire:

Enregistrer un commentaire