Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 336426

Summary: "function is ambiguous" error with SFINAE-based overloading
Product: [Tools] CDT Reporter: Nathan Ridge <zeratul976>
Component: cdt-parserAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug
Version: 8.0   
Target Milestone: 8.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
testcase + fix mschorn.eclipse: iplog-

Description Nathan Ridge CLA 2011-02-05 16:23:03 EST
For the following code:

template <bool B, class T = void>
struct enable_if {
  typedef T type;
};

template <class T>
struct enable_if<false, T> {};

template <typename T>
struct is_int
{
    static const bool value = false;
};

template <>
struct is_int<int>
{
    static const bool value = true;
};

template <typename T>
typename enable_if<!is_int<T>::value>::type function(T);

template <typename T>
typename enable_if<is_int<T>::value>::type function(T);

void g()
{
    function(0);  // ERROR HERE
}

The parser gives the error:

'function' is ambiguous ' Candidates are: void function(int) ? function(int) '

The code compiles fine with g++ (and overload resolution selects the second overload).
Comment 1 Markus Schorn CLA 2011-02-09 11:23:09 EST
Created attachment 188598 [details]
testcase + fix
Comment 2 Markus Schorn CLA 2011-02-09 11:24:01 EST
Fixed in 8.0 > 20110209.