public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mick.pearson at wildblue dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/97710] Help with breaking change? cast pointer-to-member address in template parameter list
Date: Wed, 04 Nov 2020 11:27:26 +0000	[thread overview]
Message-ID: <bug-97710-4-EMPiQfs9hQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-97710-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97710

--- Comment #2 from Mick P. <mick.pearson at wildblue dot net> ---
Sorry, I may have jumped to conclusion. I think there's a different problem
that goes like:

struct A{};
struct B:A{ int x; };
struct C:A{ T<A,(char A::*)&B::x> y; };

So T expects a pointer-to-member from A but will not cast (in template?) B's
member to an A type to satisfy the template.

The problem is with C++'s class template model it's very hard to define
pointer-to-member because they don't work like function templates, so you have
to define all of the parts of the pointer-to-member value first and satisfy
those in the parameter list, so it's easier to do casting logic inside the
template instance... and probably in my use case that's the only way to do it
for more technical reasons.

Anyway, this is a breaking-change if it's not understood. It worked in GCC 7
that I upgraded from.

These pointer-to-member values are second-class citizens in C++ since they're
really just simple short offsets (numbers) but they are a royal PITA to deal
with. We could use some tools where the standard comes up short.

  parent reply	other threads:[~2020-11-04 11:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 22:02 [Bug c++/97710] New: Help with breaking change? cast point-to-member " mick.pearson at wildblue dot net
2020-11-03 22:14 ` [Bug c++/97710] Help with breaking change? cast pointer-to-member " mpolacek at gcc dot gnu.org
2020-11-04 11:27 ` mick.pearson at wildblue dot net [this message]
2020-11-04 11:29 ` jakub at gcc dot gnu.org
2020-11-04 11:48 ` mick.pearson at wildblue dot net
2020-11-04 11:57 ` mick.pearson at wildblue dot net
2020-11-04 12:03 ` mick.pearson at wildblue dot net
2024-04-09  0:43 ` [Bug c++/97710] diagnostic for invalid pointer-to-member (not function) as template argument with base to derived should be improved pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-97710-4-EMPiQfs9hQ@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).