File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11.PHONY : test format lint
22
33test :
4- cmake ./test -B ./test/build -DCMAKE_BUILD_TYPE:STRING=Debug -G Ninja
4+ cmake ./test -B ./test/build -DCMAKE_BUILD_TYPE:STRING=Debug
55 cmake --build ./test/build --config Debug
66 cd ./test/build && ctest -C Debug --verbose
77
Original file line number Diff line number Diff line change @@ -43,13 +43,6 @@ function(
4343 list (APPEND SANITIZERS "memory" )
4444 endif ()
4545 endif ()
46-
47- list (
48- JOIN
49- SANITIZERS
50- ","
51- LIST_OF_SANITIZERS)
52-
5346 elseif (MSVC )
5447 if (${ENABLE_SANITIZER_ADDRESS} )
5548 list (APPEND SANITIZERS "address" )
@@ -62,6 +55,12 @@ function(
6255 endif ()
6356 endif ()
6457
58+ list (
59+ JOIN
60+ SANITIZERS
61+ ","
62+ LIST_OF_SANITIZERS)
63+
6564 if (LIST_OF_SANITIZERS)
6665 if (NOT
6766 "${LIST_OF_SANITIZERS} "
@@ -71,7 +70,19 @@ function(
7170 target_compile_options (${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS} )
7271 target_link_options (${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS} )
7372 else ()
73+ if ("$ENV{VCINSTALLDIR} " STREQUAL "" )
74+ message (
75+ FATAL_ERROR
76+ "Using MSVC sanitizers requires that you have set the MSVC environment before building the project. Please use the MSVC command prompt and rebuild the project. You can set up the MSVC environment using vcvarsall in cmd:
77+ # find vcvarsall.bat
78+ vswhere -products * -latest -prerelease -find \" **/VC/Auxiliary/Build/vcvarsall.bat\"
79+
80+ # set up the environment for x64
81+ \" path/to/vcvarsall\" x64
82+ " )
83+ endif ()
7484 target_compile_options (${project_name} INTERFACE /fsanitize=${LIST_OF_SANITIZERS} /Zi /INCREMENTAL:NO )
85+ target_link_options (${project_name} INTERFACE /INCREMENTAL:NO )
7586 endif ()
7687 endif ()
7788 endif ()
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ ProjectOptions(
3535 # ENABLE_USER_LINKER
3636 # ENABLE_BUILD_WITH_TIME_TRACE
3737 ENABLE_UNITY
38- # ENABLE_SANITIZER_ADDRESS
38+ ENABLE_SANITIZER_ADDRESS
3939 # ENABLE_SANITIZER_LEAK
4040 # ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
4141 # ENABLE_SANITIZER_THREAD
Original file line number Diff line number Diff line change 11// test external pac
22#include < fmt/core.h>
3+ #include < fmt/ostream.h>
34#include < Eigen/Dense>
45
56// test std libraries
@@ -19,8 +20,12 @@ int main() {
1920 fmt::print (" Hello from fmt{}" , " !" );
2021
2122 // populate an Eigen vector with the values
22- auto vec = Eigen::VectorXd::LinSpaced (10 , 0 , 1 );
23+ auto eigen_vec = Eigen::VectorXd::LinSpaced (10 , 0 , 1 );
2324
2425 // print the vector
25- fmt::print (" {}" , vec[0 ]);
26+ fmt::print (" {}" , eigen_vec);
27+
28+ // trigger address sanitizer
29+ int *p = nullptr ;
30+ *p = 1 ;
2631}
You can’t perform that action at this time.
0 commit comments