Open llvmbot opened 11 years ago
int* x; x + 100.0;
This is invalid due to a pointer plus float.
struct Y { operator int*(); }; Y() + 100.0;
Overload resolution happens here, which is more permissive. For overload resolution, there exists: int operator(int, std::ptrdiff_t); which Clang find and converts the operands for. Overload resolution tends to be a bit more permissive.
-BinaryOperator 0x6814e80 <line:24:2, col:8> 'int *' '+' |-ImplicitCastExpr 0x6814e50 <col:2, col:4> 'int *' <UserDefinedConversion> |
-CXXMemberCallExpr 0x6814e28 <col:2, col:4> 'int '
| `-MemberExpr 0x6814df8 <col:2, col:4> '-CXXTemporaryObjectExpr 0x6814840 <col:2, col:4> 'struct Y' 'void (void)' zeroing
-ImplicitCastExpr 0x6814e68
According to the AST dump, an extra ImplicitCastExpr for FloatingToIntegral is used, which prevents the error from being emitted.
Extended Description
See attached code example