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

--- Comment #3 from Bruno Haible <bruno at clisp dot org> ---
(In reply to Marek Polacek from comment #2)
> int
> fn1 (long x)
> {
>   if (0)
>     return __INT_MAX__ + 1;
> 
>   if (x || 0)
>     return __INT_MAX__ + 1; /* { dg-warning "integer overflow" } */
> 
>   if (1 || 0)
>     return __INT_MAX__ + 1; /* { dg-warning "integer overflow" } */

The rest of fn1 is dead code (at least a good dataflow analysis would detect
it). How about splitting fn1 into several functions?

int
fn11 (long x)
{
  if (0)
    return __INT_MAX__ + 1;
  return 0;
}
int
fn12 (long x)
{
  if (x || 0)
    return __INT_MAX__ + 1; /* { dg-warning "integer overflow" } */
  return 0;
}
int
fn13 (long x)
{
  if (1 || 0)
    return __INT_MAX__ + 1; /* { dg-warning "integer overflow" } */
  return 0;
}
int
fn14 (long x)
{
  if (0 && 0)
    return __INT_MAX__ + 1;
  return 0;
}
int
fn15 (long x)
{
  if (0)
    return __INT_MAX__ + 1;
  else
    return 0;
}
int
fn16 (long x)
{
  if (0)
    return 0;
  else
    return __INT_MAX__ + 1; /* { dg-warning "integer overflow" } */
}
etc.

Reply via email to