This is the mail archive of the gcc-patches@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]

Re: PATCH for division by zero in template arguments


>>>>> Mark Mitchell <mark@markmitchell.com> writes:

> OK.  Still, since programs that divide by a constant 0 are ill-formed,
> not merely undefined, I think this should be a pedwarn.

Why do you say that?

  5.6 - Multiplicative operators [expr.mul]

  -4- The binary / operator yields the quotient, and the binary % operator
  yields the remainder from the division of the first expression by the
  second. If the second operand of / or % is zero the behavior is undefined

Doesn't say anything about constant 0.  I'd prefer to follow the lead of
the C frontend on this issue.

> I also think the result of the operation should not be marked
> TREE_CONSTANT, since it's not: it's a run-time division.

I'd rather handle this by checking that the expression actually reduces to
an INTEGER_CST, as in check_cp_case_value or build_enumerator.

Jason


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