This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/19976] integer division by zero in subexpression should be overflow
- From: "pinskia at physics dot uc dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Dec 2006 03:32:33 -0000
- Subject: [Bug c/19976] integer division by zero in subexpression should be overflow
- References: <bug-19976-230@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from pinskia at physics dot uc dot edu 2006-12-01 03:32 -------
Subject: Re: integer division by zero in subexpression should be overflow
> Hi Manual,
>
> This needs to be handled in the front-ends, and in fact is already handled
^^^^^
should
> by the front-ends. In c-typeck.c:build_binary_op, I see:
>
> case TRUNC_DIV_EXPR:
> case CEIL_DIV_EXPR:
> case FLOOR_DIV_EXPR:
> case ROUND_DIV_EXPR:
> case EXACT_DIV_EXPR:
> /* Floating point division by zero is a legitimate way to obtain
> infinities and NaNs. */
> if (skip_evaluation == 0 && integer_zerop (op1))
> warning (OPT_Wdiv_by_zero, "division by zero");
>
> Likewise, there are several references to OPT_Wdiv_by_zero in cp/typeck.c.
> The real issue is that OPT_Wdiv_by_zero needs to be enabled by -pedantic
> in order to generate an error for -pedantic-errors, as requested by
> Joseph in comment #1.
Actually it is only a diagnostic problem if we are in a constant expression.
Thanks,
Andrew Pinski
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19976