PR c++/86728 - C variadic generic lambda.
[official-gcc.git] / gcc / testsuite / g++.dg / ubsan / float-cast-overflow-bf.C
blob385a109c359e86ddcf7b55c72d34910990347ef8
1 // { dg-do run { target { int32 } } }
2 // { dg-options "-fsanitize=float-cast-overflow" }
4 #define INT_MAX __INT_MAX__
5 #define INT_MIN (-__INT_MAX__ - 1)
6 #define UINT_MAX 2 * (unsigned) __INT_MAX__ + 1
8 struct S
10   int i:1;
11 } s;
13 struct T
15   unsigned int i:1;
16 } t;
18 int
19 main (void)
21   volatile double d;
23 #define CHECK_BOUNDARY(VAR, VAL)        \
24   (VAR) = (VAL) - 1.5;                  \
25   (VAR) = (VAL) - 1.0;                  \
26   (VAR) = (VAL) - 0.75;                  \
27   (VAR) = (VAL) - 0.5;                  \
28   (VAR) = (VAL) - 0.0000001;            \
29   (VAR) = (VAL) - 0.0;                  \
30   (VAR) = (VAL);                        \
31   (VAR) = (VAL) + 0.0;                  \
32   (VAR) = (VAL) + 0.0000001;            \
33   (VAR) = (VAL) + 0.5;                  \
34   (VAR) = (VAL) + 0.75;                  \
35   (VAR) = (VAL) + 1.0;                  \
36   (VAR) = (VAL) + 1.5;
38   /* Signed bit-field.  (INT_MIN, INT_MAX) is valid.  */
39   d = INT_MIN;
40   CHECK_BOUNDARY (s.i, d);
41   d = 0.0;
42   CHECK_BOUNDARY (s.i, d);
43   d = INT_MAX;
44   CHECK_BOUNDARY (s.i, d);
46   /* Unsigned bit-field.  (0, UINT_MAX) is valid.  */
47   d = UINT_MAX;
48   CHECK_BOUNDARY (t.i, d);
49   d = 0.0;
50   CHECK_BOUNDARY (t.i, d);
52   return 0;
55 /* { dg-output " -2.14748e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
56 /* { dg-output "\[^\n\r]* -2.14748e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
57 /* { dg-output "\[^\n\r]* 2.14748e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
58 /* { dg-output "\[^\n\r]* 2.14748e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
59 /* { dg-output "\[^\n\r]* 4.29497e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
60 /* { dg-output "\[^\n\r]* 4.29497e\\\+09 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
61 /* { dg-output "\[^\n\r]* -1.5 is outside the range of representable values of type\[^\n\r]*(\n|\r\n|\r)" } */
62 /* { dg-output "\[^\n\r]* -1 is outside the range of representable values of type" } */