Bug 60803 - Trivial example of overloading in the presence of inheritance fails
Summary: Trivial example of overloading in the presence of inheritance fails
Status: RESOLVED DUPLICATE of bug 97453
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.2
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: needs-bisection, rejects-valid
Depends on:
Blocks:
 
Reported: 2014-04-10 03:21 UTC by Eric Niebler
Modified: 2022-02-01 12:49 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 11.1.0
Known to fail: 10.1.0, 10.3.0, 4.8.2, 4.9.1, 5.0, 6.1.0
Last reconfirmed: 2014-12-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Niebler 2014-04-10 03:21:40 UTC
The following very simple code fails to compile:

///////////////////////////////////
template<typename Ts>
struct refines
  : Ts
{};

struct A
{};

struct B
  : refines<A>
{};

struct C
  : refines<B>
{};

void fun(void *)
{}

template<typename T>
int fun(refines<T> *)
{
  return 0;
}

int main()
{
  C *p = 0;
  int i = fun(p);
}
////////////////////
Comment 1 Daniel Krügler 2014-04-10 05:45:11 UTC
Also fails for the 4.9.0 trunk, the relevant part of the error message being

<quote>
main.cpp: In function 'int main()': 
main.cpp:29:16: error: void value not ignored as it ought to be 
     int i = fun(p); 
                  ^
</quote>
Comment 2 Andrew Pinski 2014-04-10 06:34:24 UTC
Which template argument deduction should be take, B or A?
Comment 3 Eric Niebler 2014-04-10 06:35:16 UTC
B
Comment 4 Ville Voutilainen 2014-12-14 16:22:10 UTC
Clang accepts the code.
Comment 5 Andrew Pinski 2021-08-09 20:15:11 UTC
Seems to work in GCC 11+
Comment 6 Martin Liška 2022-02-01 12:49:37 UTC
Fixed with r11-4693-ged7f9957bbb5e899.

*** This bug has been marked as a duplicate of bug 97453 ***