[cfe-dev] Bugs 2746 and 3261

Roberto Bagnara bagnara at cs.unipr.it
Tue Jan 13 08:30:02 PST 2009


Eli Friedman wrote:
> 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.

Hi Eli,

why should we restrict to unions?  For instance, the following
testcase is a simplified one coming from vstfpd-0.9.2:

struct S {
    int one;
    int two;
};

struct S const foo(void) ;

struct S tmp ;

void priv_sock_init() {
   tmp = (struct S) foo();
}

All the best,

    Roberto

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it



More information about the cfe-dev mailing list