TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
ASML C Coding Standard
Search

Rule:  6.5.15.aChecked automatically with code checker

Synopsis:The second and third operand of a conditional expression of the conditional operator shall not contain side-effects.
Language:C
Severity Level:6
Category:Expressions


Description:

Justification

Example 1

(a > b) ? i++ : j++; /* WRONG: only one of i and j are incremented */

Example 2

if (a > b) /* RIGHT */
{
   i++;
}
else
{
   j++;
}

Example 3

/* Search for "\n" in string and print the string or an error message. */                          

{
   p = strchr(string, "\n");
   printf("Result: %s\n", (p != NULL) ? p : "NOT FOUND"); /* RIGHT */
}