Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336426 - "function is ambiguous" error with SFINAE-based overloading
Summary: "function is ambiguous" error with SFINAE-based overloading
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Markus Schorn CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-05 16:23 EST by Nathan Ridge CLA
Modified: 2011-02-10 09:13 EST (History)
1 user (show)

See Also:


Attachments
testcase + fix (3.24 KB, patch)
2011-02-09 11:23 EST, Markus Schorn CLA
mschorn.eclipse: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.