[cfe-dev] bad casting in Analysis
Mike Stump
mrs at apple.com
Wed Aug 13 10:49:07 PDT 2008
Ted,
if (Op >= BinaryOperator::AndAssign)
((int&) Op) -= (BinaryOperator::AndAssign -
BinaryOperator::And);
else
((int&) Op) -= BinaryOperator::MulAssign;
produces:
GRExprEngine.cpp: In member function ‘void
clang::GRExprEngine::VisitBinaryOperator(clang::BinaryOperator*,
clang::ExplodedNode<clang::ValueState>*,
clang::ExplodedNodeSet<clang::ValueState>&)’:
GRExprEngine.cpp:2146: warning: dereferencing type-punned pointer will
break strict-aliasing rules
GRExprEngine.cpp:2148: warning: dereferencing type-punned pointer will
break strict-aliasing rules
and:
if (isa<lval::SymbolVal>(this))
return (symbol_iterator) (&Data);
else if (isa<nonlval::SymbolVal>(this))
return (symbol_iterator) (&Data);
produces:
RValues.cpp: In member function ‘const clang::SymbolID*
clang::RVal::symbol_begin() const’:
RValues.cpp:33: warning: dereferencing type-punned pointer will break
strict-aliasing rules
RValues.cpp:35: warning: dereferencing type-punned pointer will break
strict-aliasing rules
:-( The good news, if there two were cleaned up, there would be no
such warnings from clang anymore.
More information about the cfe-dev
mailing list