From 4652b66bb579bf09c921e498f2dd4c21f8669b62 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 12 Sep 2017 18:57:44 +0300 Subject: [PATCH 01/12] Add AddressSanitizer option to CMake --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd5c86140..a4248eb1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,10 @@ OPTION ( ASSIMP_WERROR "Treat warnings as errors." OFF ) +OPTION ( ASSIMP_ASAN + "Enable AddressSanitizer." + OFF +) OPTION ( SYSTEM_IRRXML "Use system installed Irrlicht/IrrXML library." OFF @@ -223,6 +227,11 @@ if (ASSIMP_WERROR) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") endif() +if (ASSIMP_ASAN) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") +endif() + INCLUDE (FindPkgMacros) INCLUDE (PrecompiledHeader) From fff800f9ab8606c0f43cd92de1b291fec1796b1c Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 12 Sep 2017 19:09:22 +0300 Subject: [PATCH 02/12] Enable AddressSanitizer for Linux clang build --- .travis.sh | 2 +- .travis.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.sh b/.travis.sh index 2b09da35e..f19c3a000 100755 --- a/.travis.sh +++ b/.travis.sh @@ -1,6 +1,6 @@ function generate() { - cmake -G "Unix Makefiles" -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -DBUILD_SHARED_LIBS=$SHARED_BUILD -DASSIMP_COVERALLS=$ENABLE_COVERALLS -DASSIMP_ERROR=ON + cmake -G "Unix Makefiles" -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -DBUILD_SHARED_LIBS=$SHARED_BUILD -DASSIMP_COVERALLS=$ENABLE_COVERALLS -DASSIMP_ERROR=ON -DASSIMP_ASAN=$ASAN } if [ $ANDROID ]; then diff --git a/.travis.yml b/.travis.yml index cf0988517..d59689f78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,16 +39,16 @@ matrix: include: - os: linux compiler: gcc - env: LINUX=1 TRAVIS_NO_EXPORT=YES ENABLE_COVERALLS=ON + env: LINUX=1 TRAVIS_NO_EXPORT=YES ENABLE_COVERALLS=ON ASAN=OFF - os: linux compiler: gcc - env: LINUX=1 TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF + env: LINUX=1 TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF ASAN=ON - os: linux compiler: gcc - env: LINUX=1 SHARED_BUILD=ON TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF + env: LINUX=1 SHARED_BUILD=ON TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF ASAN=OFF - os: linux compiler: gcc - env: LINUX=1 SHARED_BUILD=ON TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF + env: LINUX=1 SHARED_BUILD=ON TRAVIS_NO_EXPORT=NO ENABLE_COVERALLS=OFF ASAN=OFF install: - if [ $ANDROID ]; then wget -c http://dl.google.com/android/ndk/android-ndk-${PV}-${PLATF}.tar.bz2 && tar xf android-ndk-${PV}-${PLATF}.tar.bz2 ; fi From 5ecab20bd00692afff327875d360c94aec6b6016 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 12 Sep 2017 19:00:44 +0300 Subject: [PATCH 03/12] Fix delete / delete[] mismatch in glTFAsset --- code/glTFAsset.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/glTFAsset.inl b/code/glTFAsset.inl index 9284ccb02..61afebfb4 100644 --- a/code/glTFAsset.inl +++ b/code/glTFAsset.inl @@ -341,7 +341,7 @@ inline bool Buffer::LoadFromStream(IOStream& stream, size_t length, size_t baseO stream.Seek(baseOffset, aiOrigin_SET); } - mData.reset(new uint8_t[byteLength]); + mData.reset(new uint8_t[byteLength], std::default_delete()); if (stream.Read(mData.get(), byteLength, 1) != 1) { return false; From da96b32fb97e76f593e88e6093992db6500f2f7d Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Thu, 14 Sep 2017 09:38:07 +0300 Subject: [PATCH 04/12] Fix out-of-bounds read in MaterialSystem unit test --- test/unit/utMaterialSystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/utMaterialSystem.cpp b/test/unit/utMaterialSystem.cpp index f6b534f4f..80408db00 100644 --- a/test/unit/utMaterialSystem.cpp +++ b/test/unit/utMaterialSystem.cpp @@ -73,7 +73,7 @@ TEST_F(MaterialSystemTest, testFloatArrayProperty) { float pf[] = {0.0f,1.0f,2.0f,3.0f}; unsigned int pMax = sizeof(pf) / sizeof(float); - this->pcMat->AddProperty(&pf,pMax,"testKey2"); + this->pcMat->AddProperty(pf,pMax,"testKey2"); pf[0] = pf[1] = pf[2] = pf[3] = 12.0f; EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey2",0,0,pf,&pMax)); @@ -97,7 +97,7 @@ TEST_F(MaterialSystemTest, testIntArrayProperty) { int pf[] = {0,1,2,3}; unsigned int pMax = sizeof(pf) / sizeof(int); - this->pcMat->AddProperty(&pf,pMax,"testKey4"); + this->pcMat->AddProperty(pf,pMax,"testKey4"); pf[0] = pf[1] = pf[2] = pf[3] = 12; EXPECT_EQ(AI_SUCCESS, pcMat->Get("testKey4",0,0,pf,&pMax)); From efd861253d9fc89f64335abbeb08786201156428 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Thu, 14 Sep 2017 10:33:49 +0300 Subject: [PATCH 05/12] Fix delete / delete[] mismatches in MakeVerboseFormat --- code/MakeVerboseFormat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/MakeVerboseFormat.cpp b/code/MakeVerboseFormat.cpp index ee82caafe..720d44519 100644 --- a/code/MakeVerboseFormat.cpp +++ b/code/MakeVerboseFormat.cpp @@ -193,14 +193,14 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh) p = 0; while (pcMesh->HasTextureCoords(p)) { - delete pcMesh->mTextureCoords[p]; + delete[] pcMesh->mTextureCoords[p]; pcMesh->mTextureCoords[p] = apvTextureCoords[p]; ++p; } p = 0; while (pcMesh->HasVertexColors(p)) { - delete pcMesh->mColors[p]; + delete[] pcMesh->mColors[p]; pcMesh->mColors[p] = apvColorSets[p]; ++p; } From 1095ec454b9e81d8336fa41ab7109f2226a754f0 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Thu, 14 Sep 2017 10:34:16 +0300 Subject: [PATCH 06/12] Fix delete / delete[] mismatches in glTF2 importer --- code/glTF2Asset.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index 264a32d4d..ac0f353dc 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -357,7 +357,7 @@ inline bool Buffer::LoadFromStream(IOStream& stream, size_t length, size_t baseO stream.Seek(baseOffset, aiOrigin_SET); } - mData.reset(new uint8_t[byteLength]); + mData.reset(new uint8_t[byteLength], std::default_delete()); if (stream.Read(mData.get(), byteLength, 1) != 1) { return false; @@ -451,7 +451,7 @@ inline void Buffer::Grow(size_t amount) if (amount <= 0) return; uint8_t* b = new uint8_t[byteLength + amount]; if (mData) memcpy(b, mData.get(), byteLength); - mData.reset(b); + mData.reset(b, std::default_delete()); byteLength += amount; } From 29e46e4bb819f3499aa363c8df433b8c1529aa11 Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Sun, 1 Oct 2017 19:25:43 +1100 Subject: [PATCH 07/12] Addressed asan failures caused by misuse of APIs within unit tests. --- test/unit/utObjTools.cpp | 3 ++- test/unit/utSharedPPData.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/unit/utObjTools.cpp b/test/unit/utObjTools.cpp index b359cfa3a..2d9e2779f 100644 --- a/test/unit/utObjTools.cpp +++ b/test/unit/utObjTools.cpp @@ -106,8 +106,9 @@ TEST_F( utObjTools, countComponents_TwoLines_Success ) { TestObjFileParser test_parser; std::string data( "-2.061493116917992e-15 -0.9009688496589661 \\\n-0.4338837265968323" ); std::vector buffer; - buffer.resize( data.size() ); + buffer.resize( data.size() + 1 ); ::memcpy( &buffer[ 0 ], &data[ 0 ], data.size() ); + buffer[ buffer.size() - 1 ] = '\0'; test_parser.setBuffer( buffer ); size_t numComps = test_parser.testGetNumComponentsInDataDefinition(); diff --git a/test/unit/utSharedPPData.cpp b/test/unit/utSharedPPData.cpp index e075365b8..495faa7ac 100644 --- a/test/unit/utSharedPPData.cpp +++ b/test/unit/utSharedPPData.cpp @@ -92,7 +92,7 @@ TEST_F(SharedPPDataTest, testPODProperty) // ------------------------------------------------------------------------------------------------ TEST_F(SharedPPDataTest, testPropertyPointer) { - int *i = new int[35]; + int *i = new int; shared->AddProperty("test16",i); int* o; EXPECT_TRUE(shared->GetProperty("test16",o)); From 1eb7eceddfc0b7f72f2055f4c400bbd24ea7b46f Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Sun, 1 Oct 2017 23:16:21 +1100 Subject: [PATCH 08/12] Addressed a number of memory leaks identified in unit tests by asan --- code/B3DImporter.cpp | 20 ++++++++++++++++++++ code/B3DImporter.h | 2 ++ code/PretransformVertices.cpp | 2 +- test/unit/TestModelFactory.h | 8 ++++---- test/unit/utIssues.cpp | 1 + test/unit/utObjImportExport.cpp | 9 +++++++++ test/unit/utRemoveVCProcess.cpp | 3 ++- test/unit/utSceneCombiner.cpp | 7 +++++-- 8 files changed, 44 insertions(+), 8 deletions(-) diff --git a/code/B3DImporter.cpp b/code/B3DImporter.cpp index 5de7bd67c..d15676128 100644 --- a/code/B3DImporter.cpp +++ b/code/B3DImporter.cpp @@ -82,6 +82,20 @@ static const aiImporterDesc desc = { //#define DEBUG_B3D +template +void DeleteAllBarePointers(std::vector& x) +{ + for(auto p : x) + { + delete p; + } +} + +B3DImporter::~B3DImporter() +{ + DeleteAllBarePointers(_animations); +} + // ------------------------------------------------------------------------------------------------ bool B3DImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const{ @@ -558,13 +572,19 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){ void B3DImporter::ReadBB3D( aiScene *scene ){ _textures.clear(); + _materials.clear(); _vertices.clear(); + _meshes.clear(); + DeleteAllBarePointers(_nodes); _nodes.clear(); + _nodeAnims.clear(); + + DeleteAllBarePointers(_animations); _animations.clear(); string t=ReadChunk(); diff --git a/code/B3DImporter.h b/code/B3DImporter.h index 4d3576dc3..94644edd4 100644 --- a/code/B3DImporter.h +++ b/code/B3DImporter.h @@ -59,6 +59,8 @@ namespace Assimp{ class B3DImporter : public BaseImporter{ public: + B3DImporter() = default; + virtual ~B3DImporter(); virtual bool CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const; diff --git a/code/PretransformVertices.cpp b/code/PretransformVertices.cpp index 7bfed4292..5fc294618 100644 --- a/code/PretransformVertices.cpp +++ b/code/PretransformVertices.cpp @@ -634,7 +634,7 @@ void PretransformVertices::Execute( aiScene* pScene) aiNode* newRoot = new aiNode(); newRoot->mName = pScene->mRootNode->mName; delete pScene->mRootNode; - pScene->mRootNode = new aiNode(); + pScene->mRootNode = newRoot; if (1 == pScene->mNumMeshes && !pScene->mNumLights && !pScene->mNumCameras) { diff --git a/test/unit/TestModelFactory.h b/test/unit/TestModelFactory.h index 6c47dcf91..f848f5536 100644 --- a/test/unit/TestModelFactory.h +++ b/test/unit/TestModelFactory.h @@ -60,7 +60,7 @@ public: static aiScene *createDefaultTestModel( float &opacity ) { aiScene *scene( new aiScene ); scene->mNumMaterials = 1; - scene->mMaterials = new aiMaterial*; + scene->mMaterials = new aiMaterial*[scene->mNumMaterials]; scene->mMaterials[ 0 ] = new aiMaterial; aiColor3D color( 1, 0, 0 ); EXPECT_EQ( AI_SUCCESS, scene->mMaterials[ 0 ]->AddProperty( &color, 1, AI_MATKEY_COLOR_DIFFUSE ) ); @@ -70,7 +70,7 @@ public: EXPECT_EQ( AI_SUCCESS, scene->mMaterials[ 0 ]->AddProperty( &opacity, 1, AI_MATKEY_OPACITY ) ); scene->mNumMeshes = 1; - scene->mMeshes = new aiMesh*; + scene->mMeshes = new aiMesh*[scene->mNumMeshes]; scene->mMeshes[ 0 ] = new aiMesh; scene->mMeshes[ 0 ]->mMaterialIndex = 0; scene->mMeshes[ 0 ]->mPrimitiveTypes = aiPrimitiveType_TRIANGLE; @@ -80,7 +80,7 @@ public: scene->mMeshes[ 0 ]->mVertices[ 1 ] = aiVector3D( 0, 1, 0 ); scene->mMeshes[ 0 ]->mVertices[ 2 ] = aiVector3D( 0, 0, 1 ); scene->mMeshes[ 0 ]->mNumFaces = 1; - scene->mMeshes[ 0 ]->mFaces = new aiFace; + scene->mMeshes[ 0 ]->mFaces = new aiFace[scene->mMeshes[ 0 ]->mNumFaces]; scene->mMeshes[ 0 ]->mFaces[ 0 ].mNumIndices = 3; scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices = new unsigned int[ 3 ]; scene->mMeshes[ 0 ]->mFaces[ 0 ].mIndices[ 0 ] = 0; @@ -89,7 +89,7 @@ public: scene->mRootNode = new aiNode; scene->mRootNode->mNumMeshes = 1; - scene->mRootNode->mMeshes = new unsigned int( 0 ); + scene->mRootNode->mMeshes = new unsigned int[scene->mRootNode->mNumMeshes]{ 0 }; return scene; } diff --git a/test/unit/utIssues.cpp b/test/unit/utIssues.cpp index a3e68fe1a..2feef922b 100644 --- a/test/unit/utIssues.cpp +++ b/test/unit/utIssues.cpp @@ -74,6 +74,7 @@ TEST_F( utIssues, OpacityBugWhenExporting_727 ) { EXPECT_EQ( AI_SUCCESS, newScene->mMaterials[ 0 ]->Get( AI_MATKEY_OPACITY, newOpacity ) ); EXPECT_EQ( opacity, newOpacity ); } + delete scene; } #endif // ASSIMP_BUILD_NO_EXPORT diff --git a/test/unit/utObjImportExport.cpp b/test/unit/utObjImportExport.cpp index d4d4fbf9e..7099252bb 100644 --- a/test/unit/utObjImportExport.cpp +++ b/test/unit/utObjImportExport.cpp @@ -237,6 +237,15 @@ TEST_F( utObjImportExport, obj_import_test ) { differ.showReport(); m_im->FreeScene(); + for(unsigned int i = 0; i < expected->mNumMeshes; ++i) + { + delete expected->mMeshes[i]; + } + delete[] expected->mMeshes; + expected->mMeshes = nullptr; + delete[] expected->mMaterials; + expected->mMaterials = nullptr; + delete expected; } TEST_F( utObjImportExport, issue1111_no_mat_name_Test ) { diff --git a/test/unit/utRemoveVCProcess.cpp b/test/unit/utRemoveVCProcess.cpp index a42c3e858..c78e80d3f 100644 --- a/test/unit/utRemoveVCProcess.cpp +++ b/test/unit/utRemoveVCProcess.cpp @@ -72,4 +72,5 @@ TEST_F( utRevmoveVCProcess, issue1266_ProcessMeshTest_NoCrash ) { scene->mMeshes[ 0 ] = mesh; RemoveVCProcess *process = new RemoveVCProcess; process->Execute( scene ); -} \ No newline at end of file + delete scene; +} diff --git a/test/unit/utSceneCombiner.cpp b/test/unit/utSceneCombiner.cpp index f0e4d5d90..3a283515e 100644 --- a/test/unit/utSceneCombiner.cpp +++ b/test/unit/utSceneCombiner.cpp @@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "UnitTestPCH.h" #include #include +#include using namespace ::Assimp; @@ -63,8 +64,10 @@ TEST_F( utSceneCombiner, MergeMeshes_ValidNames_Test ) { mesh3->mName.Set( "mesh_3" ); merge_list.push_back( mesh3 ); - aiMesh *out( nullptr ); - SceneCombiner::MergeMeshes( &out, 0, merge_list.begin(), merge_list.end() ); + std::unique_ptr out; + aiMesh* ptr = nullptr; + SceneCombiner::MergeMeshes( &ptr, 0, merge_list.begin(), merge_list.end() ); + out.reset(ptr); std::string outName = out->mName.C_Str(); EXPECT_EQ( "mesh_1.mesh_2.mesh_3", outName ); } From 5804667dbb4798c7c20c3ef51e4e1767148f1c7c Mon Sep 17 00:00:00 2001 From: Jared Mulconry Date: Sun, 1 Oct 2017 17:51:13 +1100 Subject: [PATCH 09/12] Addressed some mismatched news/deletes caused by the new glTF2 sources. --- code/glTF2Asset.h | 2 +- code/glTF2Asset.inl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/glTF2Asset.h b/code/glTF2Asset.h index e2b61c646..63282dc6e 100644 --- a/code/glTF2Asset.h +++ b/code/glTF2Asset.h @@ -511,7 +511,7 @@ namespace glTF2 /// \fn ~SEncodedRegion() /// Destructor. - ~SEncodedRegion() { delete [] DecodedData; } + ~SEncodedRegion() { delete[] DecodedData; } }; /******************* Variables *******************/ diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index ac0f353dc..3082ebfab 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -313,7 +313,7 @@ inline void Buffer::Read(Value& obj, Asset& r) if (dataURI.base64) { uint8_t* data = 0; this->byteLength = Util::DecodeBase64(dataURI.data, dataURI.dataLength, data); - this->mData.reset(data); + this->mData.reset(data, std::default_delete()); if (statedLength > 0 && this->byteLength != statedLength) { throw DeadlyImportError("GLTF: buffer \"" + id + "\", expected " + to_string(statedLength) + @@ -326,7 +326,7 @@ inline void Buffer::Read(Value& obj, Asset& r) " bytes, but found " + to_string(dataURI.dataLength)); } - this->mData.reset(new uint8_t[dataURI.dataLength]); + this->mData.reset(new uint8_t[dataURI.dataLength], std::default_delete()); memcpy( this->mData.get(), dataURI.data, dataURI.dataLength ); } } @@ -432,7 +432,7 @@ uint8_t* new_data; // Copy data which place after replacing part. memcpy(&new_data[pBufferData_Offset + pReplace_Count], &mData.get()[pBufferData_Offset + pBufferData_Count], pBufferData_Offset); // Apply new data - mData.reset(new_data); + mData.reset(new_data, std::default_delete()); byteLength = new_data_size; return true; From 799f0a3ac8e3d0161402e4ba3e112ea41da95c9c Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 2 Oct 2017 11:40:57 +0300 Subject: [PATCH 10/12] Fix warnings-as-errors flag on MSVC --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd5c86140..ba219a443 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,8 +219,12 @@ if (ASSIMP_COVERALLS) endif() if (ASSIMP_WERROR) + IF (MSVC) + add_compile_options(/WX) + ELSE() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + ENDIF() endif() INCLUDE (FindPkgMacros) From 003c728dafd69430b4f3c7bbffa669a8c2be4764 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 2 Oct 2017 11:43:29 +0300 Subject: [PATCH 11/12] appveyor: Treat warnings as errors --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 991cf5bc1..b8828710b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,8 +29,8 @@ install: build_script: - cd c:\projects\assimp -- if "%platform%" equ "x64" (cmake CMakeLists.txt -G "Visual Studio %Configuration% Win64") -- if "%platform%" equ "x86" (cmake CMakeLists.txt -G "Visual Studio %Configuration%") +- if "%platform%" equ "x64" (cmake CMakeLists.txt -DASSIMP_WERROR=ON -G "Visual Studio %Configuration% Win64") +- if "%platform%" equ "x86" (cmake CMakeLists.txt -DASSIMP_WERROR=ON -G "Visual Studio %Configuration%") - if "%platform%" equ "x64" (msbuild /m /p:Configuration=Release /p:Platform="x64" Assimp.sln) - if "%platform%" equ "x86" (msbuild /m /p:Configuration=Release /p:Platform="Win32" Assimp.sln) From b5db7d3649f06abd153a2f81fd4da4f4f70da3a2 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Mon, 2 Oct 2017 13:08:20 +0300 Subject: [PATCH 12/12] Disable warning 4351 on MSVC 2013 --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba219a443..771800205 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,6 +203,11 @@ IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW) ELSEIF(MSVC) # enable multi-core compilation with MSVC add_compile_options(/MP) + + # disable "elements of array '' will be default initialized" warning on MSVC2013 + IF(MSVC12) + add_compile_options(/wd4351) + ENDIF() ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fvisibility=hidden -fPIC -Wall -Wno-long-long -std=c++11" ) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")