You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/testtype.cpp
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -291,7 +291,7 @@ class TestType : public TestFixture {
291
291
" if (x==123456) {}\n"
292
292
" return -123456 * x;\n"
293
293
"}",settings);
294
-
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Either the condition 'x==123456' is redundant or there is signed integer overflow for expression '-123456*x'.\n", errout_str());
294
+
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (warning) Either the condition 'x==123456' is redundant or there is signed integer underflow for expression '-123456*x'.\n", errout_str());
295
295
296
296
check("int foo(signed int x) {\n"
297
297
" if (x==123456) {}\n"
@@ -303,6 +303,16 @@ class TestType : public TestFixture {
303
303
" return (i == 31) ? 1 << i : 0;\n"
304
304
"}", settings);
305
305
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (warning) Shifting signed 32-bit value by 31 bits is undefined behaviour. See condition at line 2.\n", errout_str());
306
+
307
+
check("void f() {\n"// #13092
308
+
" int n = 0;\n"
309
+
" for (int i = 0; i < 10; i++) {\n"
310
+
" n = n * 47163 - 57412;\n"
311
+
" }\n"
312
+
"}", settings);
313
+
ASSERT_EQUALS("[test.cpp:4]: (error) Signed integer underflow for expression 'n*47163'.\n"
314
+
"[test.cpp:4]: (error) Signed integer underflow for expression 'n*47163-57412'.\n",
0 commit comments