[llvm-bugs] [Bug 32126] New: missing div-by-zero warning

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 3 03:00:39 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=32126

            Bug ID: 32126
           Summary: missing div-by-zero warning
           Product: clang
           Version: 3.9
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arnd at linaro.org
                CC: llvm-bugs at lists.llvm.org

I ran across a case where gcc turns a simple function

  static inline int return0(void) { return 0; }
  int provoke_div0_warning(void) { return 1 / return0(); }

into an unconditionally trapping instruction, but does not
warn about doing this, I opened PR79828 in gcc bugzilla
for this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79828

Cross-checking with clang revealed that the same input
instead of trapping leads to undefined behavior (returning
uninitialized register value) and also produces no warning,
even with -Weverything.

It would be nice to have a warning about this, and it could
also be useful to use a trapping instruction rather than
silent undefined behavior.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170303/a9ed887f/attachment.html>


More information about the llvm-bugs mailing list