[cfe-dev] type-punning warnings for CXXTypeidExpr::child_begin()/child_end()

Ted Kremenek kremenek at apple.com
Wed Dec 3 14:00:41 PST 2008


On Dec 3, 2008, at 1:56 PM, Chris Lattner wrote:

>
> On Dec 3, 2008, at 1:28 PM, Ted Kremenek wrote:
>
>> In ExprCXX.cpp I see:
>>
>> Stmt::child_iterator CXXTypeidExpr::child_begin() {
>>  return isTypeOperand() ? child_iterator() : (Stmt**)&Operand;
>> }
>>
>> The expression '(Stmt**)&Operand' leads to type-punning warnings
>> during a Release build.  This looks like a real issue to me.  Is this
>> safe, or do we need to fix it?  The same warning appears in  
>> child_end().
>
> This is a real bug.  "Operand" should be declared as a Stmt*.

The problem is that Operand is used as a variant to represent either a  
Type* or a Stmt*.



More information about the cfe-dev mailing list