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 c/19976] integer division by zero in subexpression should be overflow



------- 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


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