P1236R1 - Signed integers are two's complement
[official-gcc.git] / gcc / testsuite / g++.dg / ubsan / cxx11-shift-2.C
blobd104ead41758ccd2d66d437cdab357811fcc5851
1 /* { dg-do run } */
2 /* { dg-options "-fsanitize=shift -w -std=c++11" } */
4 int
5 main ()
7   int a = -42;
8   a <<= 1;
9   a = -43;
10   a <<= 0;
11   a = -44;
12   a <<= (__SIZEOF_INT__ * __CHAR_BIT__ - 1);
13   a = 32;
14   a <<= (__SIZEOF_INT__ * __CHAR_BIT__ - 3);
16 /* { dg-output "left shift of negative value -42.*" } */
17 /* { dg-output "left shift of negative value -43.*" } */
18 /* { dg-output "left shift of negative value -44.*" } */
19 /* { dg-output "left shift of 32 by \[0-9]* places cannot be represented in type 'int'" } */