Casting a parent-member function template argument to a child-member one

67 views
Skip to first unread message

bstani...@gmail.com

unread,
Aug 19, 2018, 11:44:11 AM8/19/18
to ISO C++ Standard - Discussion
Hello,

I want to make sure that I'm reading this correctly as an issue in the standard before posting to w...@edg.com . It could be that I've misunderstood the wording and this is in fact a bug in multiple compilers and not an issue with the standard.

The long story is this blog post of mine: https://ibob.github.io/blog/2018/08/18/a-bug-in-the-cpp-standard/

The short story is that this does not compile with gcc and clang and -std=c++17 (it does compile with msvc but it is not a staple of standard conformance): https://godbolt.org/z/6NQEU_

Basically I want to set a function of type (parent::*) as a template argument of a function which expects (child::*). There exists an implicit cast between those types. However even when explicitly casting the template argument to (child::*) neither gcc nor clang manage to compile it.

It suspect that the issue is in this text: "If the template-argument represents a set of overloaded functions (or a pointer or member pointer to such), the matching function is selected from the set (13.4)."  from N4198

Thanks,
Borislav




Richard Smith

unread,
Aug 19, 2018, 3:08:52 PM8/19/18
to std-dis...@isocpp.org
On Sun, 19 Aug 2018, 08:44 , <bstani...@gmail.com> wrote:
Hello,

I want to make sure that I'm reading this correctly as an issue in the standard before posting to w...@edg.com . It could be that I've misunderstood the wording and this is in fact a bug in multiple compilers and not an issue with the standard.

The long story is this blog post of mine: https://ibob.github.io/blog/2018/08/18/a-bug-in-the-cpp-standard/

The short story is that this does not compile with gcc and clang and -std=c++17 (it does compile with msvc but it is not a staple of standard conformance): https://godbolt.org/z/6NQEU_

Basically I want to set a function of type (parent::*) as a template argument of a function which expects (child::*). There exists an implicit cast between those types. However even when explicitly casting the template argument to (child::*) neither gcc nor clang manage to compile it.

The code is valid, but the Itanium C++ ABI does not specify a mangling for it yet, so compilers targeting that ABI tend to not accept it yet. Clang produces a "sorry, not supported yet" error if you try this with a class template, but unfortunately you only get a generic "bad template arguments" error in the function template case.

It suspect that the issue is in this text: "If the template-argument represents a set of overloaded functions (or a pointer or member pointer to such), the matching function is selected from the set (13.4)."  from N4198

Thanks,
Borislav




--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussio...@isocpp.org.
To post to this group, send email to std-dis...@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
Reply all
Reply to author
Forward
0 new messages