From b2d81f0870a58c65d37a66d5fd0476e86a99014e Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Sun, 19 Dec 2021 17:43:32 +0100 Subject: [PATCH] Ticket #8640: Added regression test --- test/testtype.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/testtype.cpp b/test/testtype.cpp index e3fa69c7d..f77f5f311 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -167,6 +167,17 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + // #8640 + check("int f (void)\n" + "{\n" + " constexpr const int a = 1;\n" + " constexpr const int shift[1] = {32};\n" + " constexpr const int ret = a << shift[0];\n" // shift too many bits + " return ret;\n" + "}"); + ASSERT_EQUALS("[test.cpp:5]: (error) Shifting 32-bit value by 32 bits is undefined behaviour\n" + "[test.cpp:5]: (error) Signed integer overflow for expression 'a<