lno-branch vs ptr-to-member

Mark Mitchell mark@codesourcery.com
Sun Jun 13 19:07:00 GMT 2004


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 
little insight.

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.

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com



More information about the Gcc mailing list