mercredi 11 octobre 2017

Unscoped enumeration type give an ambiguity on GCC

In the following code, declared enum with long long type . The program working fine on clang 3.8(c++14), But Gcc 7.1(c++14) give an ambiguity error.

#include <iostream>

enum : long long { Var=5 };

void fun(long long ll)
{
    std::cout << "long long : " << ll << std::endl;
}

void fun(int i)
{
    std::cout << "int : " << i <<  std::endl;
}

int main()
{
    fun(Var);
}

GCC generated error :

main.cpp: In function 'int main()':
main.cpp:17:12: error: call of overloaded 'fun(<unnamed enum>)' is ambiguous
     fun(Var);
            ^
main.cpp:5:6: note: candidate: void fun(long long int)
 void fun(long long ll)
      ^~~
main.cpp:10:6: note: candidate: void fun(int)
 void fun(int i)
      ^~~

Why does GCC give an error?

Aucun commentaire:

Enregistrer un commentaire