https://llvm.org/bugs/show_bug.cgi?id=24337
Bug ID: 24337 Summary: False negative for -Wdivision-by-zero Product: clang Version: unspecified Hardware: PC OS: Windows NT Status: NEW Severity: normal Priority: P Component: C++ Assignee: unassignedclangb...@nondot.org Reporter: dav...@freebsd.org CC: dgre...@apple.com, llvmbugs@cs.uiuc.edu Classification: Unclassified int main(void) { int z = 0; int x = 1 / z; (void)x; int y = 1 / 0; (void)y; return (0); } clang warns on the assignment of y, but it doesn't on the assignment of x. For what it's worth, GCC seems to have the same behaviour, but the two cases seems pretty much identical to me so I think we should warn on the first as well. I dug into that a little bit more, and we seem to fail evaluatingAsInt the RHS of the expression: 7428 if (RHS.get()->EvaluateAsInt(RHSValue, S.Context)) { [...] (gdb) p RHS.get()->dump() ImplicitCastExpr 0x8080c9f38 'int' <LValueToRValue> `-DeclRefExpr 0x8080c9f10 'int' lvalue Var 0x8080c9de8 'z' 'int' $7 = void Is this a limitation or is this the expected behaviour? Any ideas on how to fix this? -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ LLVMbugs mailing list LLVMbugs@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs