[cfe-dev] Bugs 2746 and 3261

Eli Friedman eli.friedman at gmail.com
Mon Jan 12 16:35:20 PST 2009


On Mon, Jan 12, 2009 at 12:42 PM, Roberto Bagnara <bagnara at cs.unipr.it> wrote:
> Eli Friedman wrote:
>>
>> On Mon, Jan 12, 2009 at 5:08 AM, Roberto Bagnara <bagnara at cs.unipr.it>
>> wrote:
>>>
>>> These are complete show-stoppers for us.  Is there any hope
>>> they may be fixed soon?  Are there workarounds (even dirty
>>> ones) we might use so as to proceed with our work?
>>> Many thanks,
>>
>> PR2746 shouldn't be too hard to implement, it's just that nobody has
>> gotten around to it yet.  It's just a matter of fixing the cast code
>> in Sema to implement additional rules when the destination type is a
>> union, and subsequently fixing CodeGen to know how to deal with it.
>
> Hi Eli,
>
> thanks for your message.  We do not use CodeGen, so perhaps all we need
> is to convince Sema (on our local copy) not to reject the code.
> Can you please give us instructions on how to achieve that?

The relevant code is in Sema::CheckCastTypes.  At a minimum, you can
add a check like "if (castType->isUnionType()) return false;"; that
should let through the code in question with very little work.  The
proper solution involves checking the legality of the cast; that
requires some code to check whether the union has a member which is
compatible with the type of the input expression.

-Eli



More information about the cfe-dev mailing list