This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR middle-end/30017 (ICE in C++ size hook)


Richard Guenther wrote:

>> Until then, I'm not sure what to suggest.  Removing the asserts will
>> actually generate wrong code.  For this input:
>>
>>   __builtin_memcpy (a, b, sizeof (*a))
>>
>> if "a" has type "C*", and "C" has virtual bases, then the C++ hook will
>> return the size of C *without virtual bases* which is wrong, since the
>> user said to copy the entire thing.  (This is what I mean by there being
>> no right answer.)  So, I think you have to disable the transformation
>> for C++, at least when the class in question has virtual bases.
> 
> ... I fail to see how the above can create wrong code removing the asserts.
> Surely if sizeof (*a) can give multiple answers the above code will look
> different after gimplification, and the transformation to an assignment
> cannot
> happen because we don't know the size (I expect a conditional in the
> gimplified version).

sizeof (*a) will be expanded by the front end to a constant, with the
correct value.  Then, Jan will turn the code into:

  *a = *b;

Then, the back end will ask "how many bytes should I copy?" using the
hook, and get the size of *a *without virtual bases* which is different
from what the user originally wrote.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]