LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 25390 - _Generic -Wdivision-by-zero bogus warning
Summary: _Generic -Wdivision-by-zero bogus warning
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: 3.5
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-03 10:28 PST by Paul Eggert
Modified: 2015-11-03 10:28 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments
program illustrating bogus warning (142 bytes, text/plain)
2015-11-03 10:28 PST, Paul Eggert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Eggert 2015-11-03 10:28:36 PST
Created attachment 15208 [details]
program illustrating bogus warning

With the attached program, clang complains

u.c:5:47: warning: division by zero is undefined [-Wdivision-by-zero]
  int j = _Generic (i, int: 0, default: 0 ? 1 / 0 : 1);
                                              ^ ~

The warning is bogus because the expression is not evaluated, for two reasons: first, it's inside a _Generic alternative not taken; second, it's inside an if-branch that's not taken.