clang emits a warning for this code: foo.c:1:25: warning: division by zero is undefined [-Wdivision-by-zero] int i = (10 > 100 ? (20 / (10 / 100)) : (20 * (100 / 10))); ^ ~~~~~~~~~~ The warning is generated for code whose value does not affect the expression result, but technically it is still 'undefined behavior'. Work around this warning by checking for a zero divisor and substituting one to make the compiler happy. Signed-off-by: Keith Packard <keithp@keithp.com> |
||
|---|---|---|
| .. | ||
| zephyr | ||