This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/79828] New: missing div-by-zero warning


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79828

            Bug ID: 79828
           Summary: missing div-by-zero warning
           Product: gcc
           Version: 7.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arnd at linaro dot org
  Target Milestone: ---

Building the kernel with gcc-7.0.1 (r245831 at the time of testing), we ran
into a warning from objtool about a function ending in an undefined
instruction:

drivers/pwm/pwm-hibvt.o: warning: objtool: hibvt_pwm_get_state() falls through
to next function hibvt_pwm_apply()

I reduced the test case to a trivial division by zero:

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

which gets turned into a single trapping instruction

(aarch64)
0000000000000018 <provoke_div0_warning>:
  18:   d4207d00        brk     #0x3e8
(x86-64)
0000000000000010 <provoke_div0_warning>:
  10:   0f 0b                   ud2    

This seems to be a result of r242636, and in the discussion
on that patch, I found a remark from Jeff Law that there
should be a warning for it:
https://gcc.gnu.org/ml/gcc-patches/2016-11/msg00508.html

I think that having this gcc warning would have been
rather useful in debugging the kernel build warning.
Any chance this could be added?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]