no warning for srem by zero?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

no warning for srem by zero?

Sanjiv Gupta
gcc generates a warning

C16-115-1.c:7: warning: division by zero

for the following code:


char *pc = (char *) 0xA0;

volatile signed char char1 = 0xFF;

int main(void)
{
  if ( char1 % 0) {
    *pc = 1;
  }
  else
    *pc = 0;
}



Why clang doesn't ?

- Sanjiv


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: no warning for srem by zero?

Eli Friedman
On Mon, Jan 11, 2010 at 8:58 AM, Sanjiv Gupta
<[hidden email]> wrote:

> gcc generates a warning
>
> C16-115-1.c:7: warning: division by zero
>
> for the following code:
>
>
> char *pc = (char *) 0xA0;
>
> volatile signed char char1 = 0xFF;
>
> int main(void)
> {
>  if ( char1 % 0) {
>    *pc = 1;
>  }
>  else
>    *pc = 0;
> }
>
>
>
> Why clang doesn't ?

No particularly good reason; feel free to file a bug.

-Eli

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev