diff --git a/code/AssetLib/STL/STLLoader.cpp b/code/AssetLib/STL/STLLoader.cpp index 702f4fe5d..2d710b084 100644 --- a/code/AssetLib/STL/STLLoader.cpp +++ b/code/AssetLib/STL/STLLoader.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -101,11 +99,13 @@ static bool IsAsciiSTL(const char *buffer, unsigned int fileSize) { const char *bufferEnd = buffer + fileSize; - if (!SkipSpaces(&buffer)) + if (!SkipSpaces(&buffer)) { return false; + } - if (buffer + 5 >= bufferEnd) + if (buffer + 5 >= bufferEnd) { return false; + } bool isASCII(strncmp(buffer, "solid", 5) == 0); if (isASCII) { @@ -370,13 +370,21 @@ void STLImporter::LoadASCIIFile(aiNode *root) { pMesh->mNumFaces = static_cast(positionBuffer.size() / 3); pMesh->mNumVertices = static_cast(positionBuffer.size()); pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; - memcpy(pMesh->mVertices, &positionBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D)); + for (size_t i=0; imNumVertices; ++i ) { + pMesh->mVertices[i].x = positionBuffer[i].x; + pMesh->mVertices[i].y = positionBuffer[i].y; + pMesh->mVertices[i].z = positionBuffer[i].z; + } positionBuffer.clear(); } // also only process normalBuffer when filled, else exception when accessing with index operator if (!normalBuffer.empty()) { pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; - memcpy(pMesh->mNormals, &normalBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D)); + for (size_t i=0; imNumVertices; ++i ) { + pMesh->mNormals[i].x = normalBuffer[i].x; + pMesh->mNormals[i].y = normalBuffer[i].y; + pMesh->mNormals[i].z = normalBuffer[i].z; + } normalBuffer.clear(); } diff --git a/code/AssetLib/glTF/glTFAsset.h b/code/AssetLib/glTF/glTFAsset.h index f0333ad0c..d6d1dd372 100644 --- a/code/AssetLib/glTF/glTFAsset.h +++ b/code/AssetLib/glTF/glTFAsset.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -61,12 +60,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#ifndef RAPIDJSON_HAS_STDSTRING #define RAPIDJSON_HAS_STDSTRING 1 +#endif + +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif + +#ifndef RAPIDJSON_NOMEMBERITERATORCLASS #define RAPIDJSON_NOMEMBERITERATORCLASS +#endif + #include #include #include +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic pop +#endif + #ifdef ASSIMP_API # include # include diff --git a/code/AssetLib/glTF2/glTF2Asset.h b/code/AssetLib/glTF2/glTF2Asset.h index fc0fe1544..ffecd3dbf 100644 --- a/code/AssetLib/glTF2/glTF2Asset.h +++ b/code/AssetLib/glTF2/glTF2Asset.h @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -63,12 +62,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#ifndef RAPIDJSON_HAS_STDSTRING #define RAPIDJSON_HAS_STDSTRING 1 +#endif + +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif + +#ifndef RAPIDJSON_NOMEMBERITERATORCLASS #define RAPIDJSON_NOMEMBERITERATORCLASS +#endif + #include #include #include +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic pop +#endif + #ifdef ASSIMP_API #include #include diff --git a/code/Common/SceneCombiner.cpp b/code/Common/SceneCombiner.cpp index eb802dd8b..5d49baaf4 100644 --- a/code/Common/SceneCombiner.cpp +++ b/code/Common/SceneCombiner.cpp @@ -66,6 +66,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Assimp { +#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif + // ------------------------------------------------------------------------------------------------ // Add a prefix to a string inline @@ -75,7 +80,7 @@ void PrefixString(aiString& string,const char* prefix, unsigned int len) { return; if (len+string.length>=MAXLEN-1) { - ASSIMP_LOG_VERBOSE_DEBUG("Can't add an unique prefix because the string is too long"); + ASSIMP_LOG_VERBOSE_DEBUG("Can't add an unique prefix because the string is too long"); ai_assert(false); return; } @@ -98,8 +103,9 @@ void SceneCombiner::AddNodeHashes(aiNode* node, std::set& hashes) } // Process all children recursively - for (unsigned int i = 0; i < node->mNumChildren;++i) + for (unsigned int i = 0; i < node->mNumChildren;++i) { AddNodeHashes(node->mChildren[i],hashes); + } } // ------------------------------------------------------------------------------------------------ @@ -1074,12 +1080,14 @@ void SceneCombiner::Copy( aiMesh** _dest, const aiMesh* src ) { GetArrayCopy( dest->mBitangents, dest->mNumVertices ); unsigned int n = 0; - while (dest->HasTextureCoords(n)) - GetArrayCopy( dest->mTextureCoords[n++], dest->mNumVertices ); + while (dest->HasTextureCoords(n)) { + GetArrayCopy( dest->mTextureCoords[n++], dest->mNumVertices ); + } n = 0; - while (dest->HasVertexColors(n)) - GetArrayCopy( dest->mColors[n++], dest->mNumVertices ); + while (dest->HasVertexColors(n)) { + GetArrayCopy( dest->mColors[n++], dest->mNumVertices ); + } // make a deep copy of all bones CopyPtrArray(dest->mBones,dest->mBones,dest->mNumBones); @@ -1341,5 +1349,9 @@ void SceneCombiner::Copy(aiMetadata** _dest, const aiMetadata* src) { } } +#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0) +# pragma GCC diagnostic pop +#endif + } // Namespace Assimp diff --git a/code/Common/SpatialSort.cpp b/code/Common/SpatialSort.cpp index 2bf6ce2e2..86e22b242 100644 --- a/code/Common/SpatialSort.cpp +++ b/code/Common/SpatialSort.cpp @@ -210,20 +210,16 @@ BinFloat ToBinary(const ai_real &pValue) { // See http://en.wikipedia.org/wiki/Signed_number_representations. // Two's complement? - bool DefaultValue = ((-42 == (~42 + 1)) && (binValue & 0x80000000)); - bool OneComplement = ((-42 == ~42) && (binValue & 0x80000000)); - bool SignedMagnitude = ((-42 == (42 | (-0))) && (binValue & 0x80000000)); + const bool DefaultValue = ((-42 == (~42 + 1)) && (binValue & 0x80000000)); + const bool OneComplement = ((-42 == ~42) && (binValue & 0x80000000)); if (DefaultValue) return BinFloat(1 << (CHAR_BIT * sizeof(BinFloat) - 1)) - binValue; // One's complement? else if (OneComplement) return BinFloat(-0) - binValue; - // Sign-magnitude? - else if (SignedMagnitude) // -0 = 1000... binary - return binValue; - else - return binValue; + // Sign-magnitude? -0 = 1000... binary + return binValue; } } // namespace diff --git a/contrib/rapidjson/include/rapidjson/document.h b/contrib/rapidjson/include/rapidjson/document.h index 93b091f64..473d846e3 100644 --- a/contrib/rapidjson/include/rapidjson/document.h +++ b/contrib/rapidjson/include/rapidjson/document.h @@ -17,6 +17,11 @@ /*! \file document.h */ +#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif + #include "reader.h" #include "internal/meta.h" #include "internal/strfunc.h" @@ -2610,4 +2615,8 @@ private: RAPIDJSON_NAMESPACE_END RAPIDJSON_DIAG_POP +#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0) +#pragma GCC diagnostic pop +#endif + #endif // RAPIDJSON_DOCUMENT_H_ diff --git a/test/unit/utFindInvalidData.cpp b/test/unit/utFindInvalidData.cpp index e7dc123bb..17a9c0379 100644 --- a/test/unit/utFindInvalidData.cpp +++ b/test/unit/utFindInvalidData.cpp @@ -106,8 +106,10 @@ void utFindInvalidDataProcess::TearDown() { // ------------------------------------------------------------------------------------------------ TEST_F(utFindInvalidDataProcess, testStepNegativeResult) { - ::memset(mMesh->mNormals, 0, mMesh->mNumVertices * sizeof(aiVector3D)); - ::memset(mMesh->mBitangents, 0, mMesh->mNumVertices * sizeof(aiVector3D)); + for ( size_t i=0; imNumVertices; ++i ) { + mMesh->mNormals[i].x = mMesh->mNormals[i].y = mMesh->mNormals[i].z =0; + mMesh->mBitangents[i].x = mMesh->mBitangents[i].y = mMesh->mBitangents[i].z = 0; + } mMesh->mTextureCoords[2][455] = aiVector3D(std::numeric_limits::quiet_NaN());