Bug 24628 - const-over-non-const identification fails
Summary: const-over-non-const identification fails
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: 4.0.3
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-02 01:17 UTC by Ivan Godard
Modified: 2005-11-02 15:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.0 4.0.3
Known to fail: 3.4.0 3.4.5 3.3.6 2.95.3 3.2.3 3.0.4
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Godard 2005-11-02 01:17:18 UTC
template<typename T>
void foo(T& t) {}
template<typename T>
void foo(const T& t) {}

template<typename U, int n, typename T>
void bar(T& t) {}
template<typename U, int n, typename T>
void bar(const T& t) {}

int main() {
    int i;
    const int j = 0;
    foo(i);
    foo(j);
    bar<bool, 5>(i);
    bar<bool, 5>(j);
    }

gets you

foo.cc: In function `int main()':
foo.cc:17: error: call of overloaded `bar(const int&)' is ambiguous
foo.cc:7: note: candidates are: void bar(T&) [with U = bool, int n = 5, T = const int]
foo.cc:9: note:                 void bar(const T&) [with U = bool, int n = 5, T = int]
Comment 1 Andrew Pinski 2005-11-02 01:21:42 UTC
This works on the mainline at least.
Comment 2 Andrew Pinski 2005-11-02 15:05:23 UTC
And works in 4.0.3 but not in 3.4.5 and 3.4.0.  


Closing as fixed for 4.0.3 since this was not a regression.