[cfe-dev] Divide by zero reporting

Jordan Rose jordan_rose at apple.com
Tue Dec 11 09:13:59 PST 2012


Hi, Sujit. The checkers in the analyzer can choose to treat errors as fatal or non-fatal. In the case of divide-by-zero errors, we treat them as fatal, because (a) they will in fact trap in most runtimes, and (b) it's hard to continue evaluating if the division is used in a larger expression:

int a = 23 / 0;
int b = 34 / a; // ??

Note that the analyzer only stops analyzing a particular path when it sees a fatal error, not the entire file. Both divide-by-zero violations should be reported in compute(), as well as the one in again(), even if both functions are in the same file.

int compute(int a) {
	if (coin()) {
		a = a / 0;
	} else {
		a = a / 0;
	}
}

int again() {
	return 24 / 0;
}

Best,
Jordan



On Dec 11, 2012, at 1:36 , Sujit Kamthe <Sujit.Kamthe at kpitcummins.com> wrote:

> Hi,
> While running clang tool on a code it was found that if there are multiple divide by zero violations(more than 1) in same file then only the first one is reported and rest of them are not reported.
> Even it was found that when a Prestmt<BinaryOperator> check detects/emits a bugreport, it skips the subsequent binary operator nodes from the same file.
>  
> Example Code:
>  
> int a=23/0; //Detected and reported
> int b=34/0; //Not detected
>  
> Regards,
> Sujit Kamthe
>  
> 
> This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails. _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121211/ac2bae04/attachment.html>


More information about the cfe-dev mailing list