aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/pr56607.c
blob: d7faa81151a261024b06f3b9156ac60cd5da9f8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* PR c++/56607 */
/* { dg-do compile { target { { lp64 || ilp32 } || llp64 } } } */
/* { dg-options "-O2 -Wdiv-by-zero" } */

int
f1 (void)
{
  return 1 / (sizeof (char) - 1);	/* { dg-warning "division by zero" } */
}

int
f2 (void)
{
  const int x = sizeof (char) - 1;
  return 1 / x;				/* { dg-warning "division by zero" "" { target c++ } } */
}

int
f3 (void)
{
  return 1 / (sizeof (int) / 3 - 1);	/* { dg-warning "division by zero" } */
}

int
f4 (void)
{
  const int x = sizeof (int) / 3 - 1;
  return 1 / x;				/* { dg-warning "division by zero" "" { target c++ } } */
}