This is the mail archive of the 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)

the overall plan sounds very good to me, just minor questions
> Right.  It may be that the only way to fix this is to follow through on
> the project Jason and I have discussed to change TYPE_SIZE_UNIT for C++
> class types, because it looks like C++ is the only language that uses
> the hook, and it does two things:
> (1) Return the smaller size for classes with virtual base classes.
> (2) Return zero for empty classes.
> The empty-class optimization could well go into the middle-end; we could
> have a bit on types that marks them as empty, so that even if they have
> non-zero size, the middle-end still knows they have no useful data.

Interesting.  How this is different from setting TYPE_SIZE_UNIT to 0 in
these cases?
> To deal with (1), we probably need to finally grit our teeth and change
> the C++ type representation so that (as Jason and I have previously
> agreed), we use the as-base type for C++ pointers.  Then, the hook can go.
> 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.
> It would probably be OK to simplify the assert in C++ to checking that
> CLASSTYPE_SIZE_UNIT == TYPE_SIZE_UNIT.  If those two are the same, then
> virtual bases don't matter.  And, I guess at this point, we could trust
> the backend not to generate invalid copies, so we could lose the
> asertions about assignment operators and copy constructors.
> So, my short-term suggestion:
> 1. Disable the transformation unless TYPE_SIZE_UNIT == CLASSTYPE_SIZE_UNIT.
> 2. Change the C++ hook to assert that TYPE_SIZE_UNIT == CLASSTYPE_SIZE_UNIT.

OK, this sounds like good short-term plan.  However how can I check
the conditional in common code where CLASSTYPE_SIZE_UNIT is not defined?
(ie the idea of making expr_size return NULL in the wrong cases and
adding check that expr_size is same as TYPE_SIZE_UNIT might avoid need
to deal with CLASSTYPE in the builtins.c)

> -- 
> Mark Mitchell
> CodeSourcery
> (650) 331-3385 x713

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