This is the mail archive of the
mailing list for the GCC project.
Re: lno-branch vs ptr-to-member
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>, Dale Johannesen <dalej at apple dot com>,Sebastian Pop <sebastian dot pop at cri dot ensmp dot fr>, gcc_mailing_list List <gcc at gcc dot gnu dot org>
- Date: Sun, 13 Jun 2004 12:06:58 -0700
- Subject: Re: lno-branch vs ptr-to-member
- Organization: CodeSourcery, LLC
- References: <200406090034.i590YaS28071@tin.geop.uc.edu>
Andrew Pinski wrote:
Calling convert from the middle-end is asking for troubles.
interesting; we do it moreorless everwhere (dom, sra, ccp, ...).
I see this thread is coming to a conclusion, but I'll try to offer a
First, there are two kinds of pointers-to-members: pointers to data
members and pointers to function members. The former are just offsets
into an object; for example an "int S::*" is just the offset from the
start of "S" to some "int" data member (i.e., field) in "S". Pointers
to function members are more complex: they explain how to call a
particular member function. So an "int (S::*)(double)" explains how to
call a member function of "S" that takes a "double" and returns an "int"
-- given a pointer to an "S". The implementation of this idea is a
little structure: one part of the structure explains how to adjust the
"this" pointer and the other is either a function pointer or a vtable index.
It makes no sense to try to convert pointers to function members to
integers, but it is reasonable to do that with pointers to data members.
It is true that all uses of "convert" outside of the front end are
suspect. Most of them happen to work, but "convert" is a
language-dependent routine, and as such it tends to create
language-specific structures. There should be another routine that can
be used by the middle end to do conversions that are known to be OK like
converting from an integer to a pointer and back, or converting from one
integer type to another, or from one pointer to another.