File tree Expand file tree Collapse file tree 8 files changed +94
-0
lines changed
Expand file tree Collapse file tree 8 files changed +94
-0
lines changed Original file line number Diff line number Diff line change 1+ BasedOnStyle : LLVM
2+ Language : Cpp
3+ Standard : Cpp11
4+ IndentWidth : 4
5+ ColumnLimit : 100
6+ BinPackParameters : false
7+ AlwaysBreakTemplateDeclarations : true
8+ PenaltyReturnTypeOnItsOwnLine : 10000
9+ BreakConstructorInitializers : AfterColon
10+ ConstructorInitializerAllOnOneLineOrOnePerLine : true
Original file line number Diff line number Diff line change 1+ * build * /
Original file line number Diff line number Diff line change 1+ cmake_minimum_required ( VERSION 3.10 )
2+ project ( sanitizer-tests C CXX )
3+
4+ include (../c++-standards.cmake)
5+ include (../code-coverage.cmake)
6+ include (../sanitizers.cmake)
7+ include (../tools.cmake)
8+
9+ # Require C++11
10+ cxx_11()
11+
12+ enable_testing ()
13+
14+ add_executable (tsanFail tsan_fail.cpp)
15+ target_code_coverage(tsanFail AUTO ALL )
16+ if (UNIX )
17+ target_link_libraries (tsanFail PUBLIC pthread)
18+ endif ()
19+ add_test (tsan tsanFail)
20+
21+ add_executable (lsanFail lsan_fail.c)
22+ target_code_coverage(lsanFail AUTO ALL )
23+ add_test (lsan lsanFail)
24+
25+ if (USE_SANITIZER MATCHES "[Aa]ddress" )
26+ add_executable (asanFail asan_fail.cpp)
27+ target_code_coverage(asanFail AUTO ALL )
28+ add_test (asan asanFail)
29+ endif ()
30+
31+ add_executable (msanFail msan_fail.cpp)
32+ target_code_coverage(msanFail AUTO ALL )
33+ add_test (msan msanFail)
34+
35+ add_executable (ubsanFail ubsan_fail.cpp)
36+ target_code_coverage(ubsanFail AUTO ALL )
37+ add_test (ubsan ubsanFail)
Original file line number Diff line number Diff line change 1+ int main (int argc, char **argv) {
2+ int *array = new int [100 ];
3+ delete[] array;
4+ return array[argc]; // BOOM
5+ }
Original file line number Diff line number Diff line change 1+ #include <stdlib.h>
2+ void * p ;
3+ int main () {
4+ p = malloc (7 );
5+ p = 0 ; // The memory is leaked here.
6+ return 0 ;
7+ }
Original file line number Diff line number Diff line change 1+ #include < stdio.h>
2+
3+ int main (int argc, char **argv) {
4+ int *a = new int [10 ];
5+ a[5 ] = 0 ;
6+ if (a[argc])
7+ printf (" xx\n " );
8+ return 0 ;
9+ }
Original file line number Diff line number Diff line change 1+ #include < functional>
2+ #include < map>
3+ #include < stdio.h>
4+ #include < string>
5+ #include < thread>
6+
7+ typedef std::map<std::string, std::string> map_t ;
8+
9+ void *threadfunc (void *p) {
10+ map_t &m = *(map_t *)p;
11+ m[" foo" ] = " bar" ;
12+ return 0 ;
13+ }
14+
15+ int main () {
16+ map_t m;
17+ std::thread t (threadfunc, &m);
18+ printf (" foo=%s\n " , m[" foo" ].c_str ());
19+ t.join ();
20+ }
Original file line number Diff line number Diff line change 1+ int main (int argc, char **argv) {
2+ int k = 0x7fffffff ;
3+ k += argc;
4+ return 0 ;
5+ }
You can’t perform that action at this time.
0 commit comments