Bug 510810 - Only one candidate displayed for ambiguous function call
Summary: Only one candidate displayed for ambiguous function call
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: Next   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: CDT Codan Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-21 21:51 EST by Marc-André Laperle CLA
Modified: 2017-01-22 03:05 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-André Laperle CLA 2017-01-21 21:51:20 EST
template <typename A, typename B>
void foo(A* a, B b) {
}

template <typename A, typename B>
void foo(A a, B* b) {
}

int main() {
	int *i, *j; 
	foo(j, i);  
	return 0;
}

The error displayed is :
'foo' is ambiguous '
Candidates are:
void foo(int *, int *)
'

Perhaps instead it should display:
void foo(int *, int)
void foo(int, int*)
Comment 1 Nathan Ridge CLA 2017-01-22 03:05:47 EST
(In reply to Marc-André Laperle from comment #0)
> Perhaps instead it should display:
> void foo(int *, int)
> void foo(int, int*)

It should not display that. The instantiated signatures are both 'foo(int*, int*)' (the first arising from instantiating the first template with A=int and B=int*, and the second arising from instantiating the second template with A=int* and B=int).

Here's what gcc displays:

  void foo(A*, B) [with A = int; B = int*]
  void foo(A, B*) [with A = int*; B = int]

That would be a better thing for us to display too.