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
@@ -3789,40 +3790,40 @@ class TestBufferOverrun : public TestFixture {
3789
3790
check("void f() {\n"
3790
3791
" char a[10];\n"
3791
3792
" char *p = a + 100;\n"
3792
-
"}");
3793
+
"}", settings0_p);
3793
3794
ASSERT_EQUALS("[test.cpp:3:17]: (portability) Undefined behaviour, pointer arithmetic 'a+100' is out of bounds. [pointerOutOfBounds]\n", errout_str());
3794
3795
3795
3796
check("char *f() {\n"
3796
3797
" char a[10];\n"
3797
3798
" return a + 100;\n"
3798
-
"}");
3799
+
"}", settings0_p);
3799
3800
ASSERT_EQUALS("[test.cpp:3:14]: (portability) Undefined behaviour, pointer arithmetic 'a+100' is out of bounds. [pointerOutOfBounds]\n", errout_str());
3800
3801
3801
3802
check("void f(int i) {\n"
3802
3803
" char x[10];\n"
3803
3804
" if (i == 123) {}\n"
3804
3805
" dostuff(x+i);\n"
3805
-
"}");
3806
+
"}", settings0_p);
3806
3807
ASSERT_EQUALS("[test.cpp:3:11] -> [test.cpp:4:14]: (portability) Undefined behaviour, when 'i' is 123 the pointer arithmetic 'x+i' is out of bounds. [pointerOutOfBoundsCond]\n", errout_str());
3807
3808
3808
3809
check("void f(int i) {\n"
3809
3810
" char x[10];\n"
3810
3811
" if (i == -1) {}\n"
3811
3812
" dostuff(x+i);\n"
3812
-
"}");
3813
+
"}", settings0_p);
3813
3814
ASSERT_EQUALS("[test.cpp:3:11] -> [test.cpp:4:14]: (portability) Undefined behaviour, when 'i' is -1 the pointer arithmetic 'x+i' is out of bounds. [pointerOutOfBoundsCond]\n", errout_str());
3814
3815
3815
3816
check("void f() {\n"// #6350 - fp when there is cast of buffer
3816
3817
" wchar_t buf[64];\n"
3817
3818
" p = (unsigned char *) buf + sizeof (buf);\n"
3818
-
"}", dinit(CheckOptions, $.cpp = false));
3819
+
"}", settings0_p, false);
3819
3820
ASSERT_EQUALS("", errout_str());
3820
3821
3821
3822
check("int f() {\n"
3822
3823
" const char d[] = \"0123456789\";\n"
3823
3824
" char *cp = d + 3;\n"
3824
3825
" return cp - d;\n"
3825
-
"}");
3826
+
"}", settings0_p);
3826
3827
ASSERT_EQUALS("", errout_str());
3827
3828
}
3828
3829
@@ -3831,15 +3832,15 @@ class TestBufferOverrun : public TestFixture {
3831
3832
" char *p = malloc(10);\n"
3832
3833
" p += 100;\n"
3833
3834
" free(p);"
3834
-
"}");
3835
+
"}", settings0_p);
3835
3836
TODO_ASSERT_EQUALS("[test.cpp:3]: (portability) Undefined behaviour, pointer arithmetic 'p+100' is out of bounds.\n", "", errout_str());
3836
3837
3837
3838
check("void f() {\n"
3838
3839
" char *p = malloc(10);\n"
3839
3840
" p += 10;\n"
3840
3841
" *p = 0;\n"
3841
3842
" free(p);"
3842
-
"}");
3843
+
"}", settings0_p);
3843
3844
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) p is out of bounds.\n", "", errout_str());
3844
3845
3845
3846
check("void f() {\n"
@@ -3848,7 +3849,7 @@ class TestBufferOverrun : public TestFixture {
3848
3849
" p -= 10;\n"
3849
3850
" *p = 0;\n"
3850
3851
" free(p);"
3851
-
"}");
3852
+
"}", settings0_p);
3852
3853
ASSERT_EQUALS("", errout_str());
3853
3854
3854
3855
check("void f() {\n"
@@ -3857,15 +3858,15 @@ class TestBufferOverrun : public TestFixture {
3857
3858
" p = p - 1;\n"
3858
3859
" *p = 0;\n"
3859
3860
" free(p);"
3860
-
"}");
3861
+
"}", settings0_p);
3861
3862
ASSERT_EQUALS("", errout_str());
3862
3863
}
3863
3864
3864
3865
voidpointer_out_of_bounds_3() {
3865
3866
check("struct S { int a[10]; };\n"
3866
3867
"void f(struct S *s) {\n"
3867
3868
" int *p = s->a + 100;\n"
3868
-
"}");
3869
+
"}", settings0_p);
3869
3870
ASSERT_EQUALS("[test.cpp:3:19]: (portability) Undefined behaviour, pointer arithmetic 's->a+100' is out of bounds. [pointerOutOfBounds]\n", errout_str());
3870
3871
3871
3872
check("template <class T> class Vector\n"
@@ -3881,36 +3882,36 @@ class TestBufferOverrun : public TestFixture {
ASSERT_EQUALS("[test.cpp:2:15]: (portability) Undefined behaviour, pointer arithmetic '\"Hello\"+7' is out of bounds. [pointerOutOfBounds]\n", errout_str());
3898
3899
3899
3900
check("const char16_t* f() {\n"
3900
3901
" g(u\"Hello\" + 6);\n"
3901
-
"}");
3902
+
"}", settings0_p);
3902
3903
ASSERT_EQUALS("", errout_str());
3903
3904
3904
3905
check("const char16_t* f() {\n"
3905
3906
" g(u\"Hello\" + 7);\n"
3906
-
"}");
3907
+
"}", settings0_p);
3907
3908
ASSERT_EQUALS("[test.cpp:2:16]: (portability) Undefined behaviour, pointer arithmetic 'u\"Hello\"+7' is out of bounds. [pointerOutOfBounds]\n", errout_str());
3908
3909
3909
3910
check("void f() {\n"// #4647
3910
3911
" int val = 5;\n"
3911
3912
" std::string hi = \"hi\" + val;\n"
3912
3913
" std::cout << hi << std::endl;\n"
3913
-
"}\n");
3914
+
"}\n", settings0_p);
3914
3915
ASSERT_EQUALS("[test.cpp:3:27]: (portability) Undefined behaviour, pointer arithmetic '\"hi\"+val' is out of bounds. [pointerOutOfBounds]\n", errout_str());
3915
3916
3916
3917
check("void f(const char* s, int len) {\n"// #11026
@@ -3920,7 +3921,7 @@ class TestBufferOverrun : public TestFixture {
3920
3921
"void g() {\n"
3921
3922
" f(\"a\", 1);\n"
3922
3923
" f(\"bbb\", 3);\n"
3923
-
"}\n");
3924
+
"}\n", settings0_p);
3924
3925
ASSERT_EQUALS("", errout_str());
3925
3926
3926
3927
check("void f(int i, const char* a) {\n"// #11140
@@ -3933,14 +3934,14 @@ class TestBufferOverrun : public TestFixture {
@@ -3950,26 +3951,26 @@ class TestBufferOverrun : public TestFixture {
3950
3951
check("char *f() {\n"
3951
3952
" char x[10];\n"
3952
3953
" return x-1;\n"
3953
-
"}");
3954
+
"}", settings0_p);
3954
3955
ASSERT_EQUALS("[test.cpp:3:13]: (portability) Undefined behaviour, pointer arithmetic 'x-1' is out of bounds. [pointerOutOfBounds]\n", errout_str());
3955
3956
3956
3957
check("void f(int i) {\n"
3957
3958
" char x[10];\n"
3958
3959
" if (i == 123) {}\n"
3959
3960
" dostuff(x-i);\n"
3960
-
"}");
3961
+
"}", settings0_p);
3961
3962
ASSERT_EQUALS("[test.cpp:3:11] -> [test.cpp:4:14]: (portability) Undefined behaviour, when 'i' is 123 the pointer arithmetic 'x-i' is out of bounds. [pointerOutOfBoundsCond]\n", errout_str());
3962
3963
3963
3964
check("void f(int i) {\n"
3964
3965
" char x[10];\n"
3965
3966
" if (i == -20) {}\n"
3966
3967
" dostuff(x-i);\n"
3967
-
"}");
3968
+
"}", settings0_p);
3968
3969
TODO_ASSERT_EQUALS("[test.cpp:4]: (portability) Undefined behaviour, when 'i' is -20 the pointer arithmetic 'x-i' is out of bounds.\n", "", errout_str());
3969
3970
3970
3971
check("void f(const char *x[10]) {\n"
3971
3972
" return x-4;\n"
3972
-
"}");
3973
+
"}", settings0_p);
3973
3974
ASSERT_EQUALS("", errout_str());
3974
3975
}
3975
3976
@@ -5296,14 +5297,14 @@ class TestBufferOverrun : public TestFixture {
5296
5297
check("void f() {\n"
5297
5298
" char arr[10];\n"
5298
5299
" char *p = arr + 20;\n"
5299
-
"}");
5300
+
"}", settings0_p);
5300
5301
ASSERT_EQUALS("[test.cpp:3:19]: (portability) Undefined behaviour, pointer arithmetic 'arr+20' is out of bounds. [pointerOutOfBounds]\n", errout_str());
0 commit comments