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

            Bug ID: 99669
           Summary: RFE: detect division by zero in analyzer
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

-fanalyzer could probably warn about division by zero:

Consider this easy case (from
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89863#c7):

extern void g();

void f()
{
    unsigned int vsync_rate_hz = 0;
    unsigned int frame_time_microsec = 1000000 / vsync_rate_hz;

    g();
}

See also bug 80744 (same idea but for C++)

PVS-Studio complains about this:
  https://www.viva64.com/en/w/v609/
  https://www.viva64.com/en/examples/v609/
which has interprocedural examples, and an example of a loop where we could
"know" that the iterator could be zero.

CWE-369: Divide By Zero:
  https://cwe.mitre.org/data/definitions/369.html

Reply via email to