1 /* { dg-do run } */
2 /* { dg-options "-fsanitize=float-cast-overflow" } */
3 
4 struct
5 {
6   int i:1;
7 } s;
8 
9 struct
10 {
11   unsigned int i:1;
12 } t;
13 
14 int
main(void)15 main (void)
16 {
17   volatile double d;
18 
19 #define CHECK_BOUNDARY(VAR, VAL)        \
20   (VAR) = (VAL) - 1.5;                  \
21   (VAR) = (VAL) - 1.0;                  \
22   (VAR) = (VAL) - 0.5;                  \
23   (VAR) = (VAL) - 0.0000001;            \
24   (VAR) = (VAL) - 0.0;                  \
25   (VAR) = (VAL);                        \
26   (VAR) = (VAL) + 0.0;                  \
27   (VAR) = (VAL) + 0.0000001;            \
28   (VAR) = (VAL) + 0.5;                  \
29   (VAR) = (VAL) + 1.0;                  \
30   (VAR) = (VAL) + 1.5;
31 
32   /* Signed bit-field.  (-1, 0) is valid.  */
33   d = -1.0;
34   CHECK_BOUNDARY (s.i, d);
35   d = 0.0;
36   CHECK_BOUNDARY (s.i, d);
37   d = 1.0;
38   CHECK_BOUNDARY (s.i, d);
39 
40   /* Unsigned bit-field.  (0, 1) is valid.  */
41   d = -1.0;
42   CHECK_BOUNDARY (t.i, d);
43   d = 0.0;
44   CHECK_BOUNDARY (t.i, d);
45   d = 1.0;
46   CHECK_BOUNDARY (t.i, d);
47 
48   return 0;
49 }
50 
51 /* { dg-output " -2.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
52 /* { dg-output "\[^\n\r]* -2 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
53 /* { dg-output "\[^\n\r]* 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
54 /* { dg-output "\[^\n\r]* 1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
55 /* { dg-output "\[^\n\r]* 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
56 /* { dg-output "\[^\n\r]* 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
57 /* { dg-output "\[^\n\r]* 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
58 /* { dg-output "\[^\n\r]* 1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
59 /* { dg-output "\[^\n\r]* 1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
60 /* { dg-output "\[^\n\r]* 2 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
61 /* { dg-output "\[^\n\r]* 2.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
62 /* { dg-output "\[^\n\r]* -2.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
63 /* { dg-output "\[^\n\r]* -2 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
64 /* { dg-output "\[^\n\r]* -1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
65 /* { dg-output "\[^\n\r]* -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
66 /* { dg-output "\[^\n\r]* -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
67 /* { dg-output "\[^\n\r]* -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
68 /* { dg-output "\[^\n\r]* -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
69 /* { dg-output "\[^\n\r]* -1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
70 /* { dg-output "\[^\n\r]* -1 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
71 /* { dg-output "\[^\n\r]* 2 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
72 /* { dg-output "\[^\n\r]* 2.5 is outside the range of representable values of type" } */
73