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
ASSERT_EQUALS("[test.cpp:3:6]: (error) Array 'a[" + charMaxPlusOne + "]' accessed at index -1, which is out of bounds. [negativeIndex]\n"
"[test.cpp:4:6]: (error) Array 'a[" + charMaxPlusOne + "]' accessed at index " + charMaxPlusOne + ", which is out of bounds. [arrayIndexOutOfBounds]\n", errout_str());
check("void f(signed char n) {\n"
" int a[n];\n"// n <= SCHAR_MAX
" a[-1] = 0;\n"// negative index
" a[128] = 0;\n"// 128 > SCHAR_MAX
"}\n");
ASSERT_EQUALS("[test.cpp:3:6]: (error) Array 'a[128]' accessed at index -1, which is out of bounds. [negativeIndex]\n"
"[test.cpp:4:6]: (error) Array 'a[128]' accessed at index 128, which is out of bounds. [arrayIndexOutOfBounds]\n", errout_str());
check("void f(unsigned char n) {\n"
" int a[n];\n"// n <= UCHAR_MAX
" a[-1] = 0;\n"// negative index
" a[256] = 0;\n"// 256 > UCHAR_MAX
"}\n");
ASSERT_EQUALS("[test.cpp:3:6]: (error) Array 'a[256]' accessed at index -1, which is out of bounds. [negativeIndex]\n"
"[test.cpp:4:6]: (error) Array 'a[256]' accessed at index 256, which is out of bounds. [arrayIndexOutOfBounds]\n", errout_str());
check("void f(short n) {\n"
" int a[n];\n"// n <= SHRT_MAX
" a[-1] = 0;\n"// negative index
" a[32768] = 0;\n"// 32768 > SHRT_MAX
"}\n");
ASSERT_EQUALS("[test.cpp:3:6]: (error) Array 'a[32768]' accessed at index -1, which is out of bounds. [negativeIndex]\n"
"[test.cpp:4:6]: (error) Array 'a[32768]' accessed at index 32768, which is out of bounds. [arrayIndexOutOfBounds]\n", errout_str());
check("void f(unsigned short n) {\n"
" int a[n];\n"// n <= USHRT_MAX
" a[-1] = 0;\n"// negative index
" a[65536] = 0;\n"// 65536 > USHRT_MAX
"}\n");
ASSERT_EQUALS("[test.cpp:3:6]: (error) Array 'a[65536]' accessed at index -1, which is out of bounds. [negativeIndex]\n"
"[test.cpp:4:6]: (error) Array 'a[65536]' accessed at index 65536, which is out of bounds. [arrayIndexOutOfBounds]\n", errout_str());
check("void f(signed short n) {\n"
" int a[n];\n"// n <= SHRT_MAX
" a[-1] = 0;\n"// negative index
" a[32768] = 0;\n"// 32768 > SHRT_MAX
"}\n");
ASSERT_EQUALS("[test.cpp:3:6]: (error) Array 'a[32768]' accessed at index -1, which is out of bounds. [negativeIndex]\n"
"[test.cpp:4:6]: (error) Array 'a[32768]' accessed at index 32768, which is out of bounds. [arrayIndexOutOfBounds]\n", errout_str());
check("void f(int n) {\n"
" int a[n];\n"// n <= INT_MAX
" a[-1] = 0;\n"// negative index
"}\n");
ASSERT_EQUALS("[test.cpp:3:6]: (error) Array 'a[2147483648]' accessed at index -1, which is out of bounds. [negativeIndex]\n", errout_str());
check("void f(unsigned int n) {\n"
" int a[n];\n"// n <= UINT_MAX
" a[-1] = 0;\n"// negative index
"}\n");
ASSERT_EQUALS("[test.cpp:3:6]: (error) Array 'a[4294967296]' accessed at index -1, which is out of bounds. [negativeIndex]\n", errout_str());
check("void f(signed int n) {\n"
" int a[n];\n"// n <= INT_MAX
" a[-1] = 0;\n"// negative index
"}\n");
ASSERT_EQUALS("[test.cpp:3:6]: (error) Array 'a[2147483648]' accessed at index -1, which is out of bounds. [negativeIndex]\n", errout_str());