Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pedantic compile with MSVC, GCC and Clang MinGW #4623

Open
wants to merge 97 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
8e2e017
Compiler warnings - unused parameters, variable, function, private-field
RaceTheMaSe Mar 8, 2024
c1bcea7
Compiler warnings - initialization order
RaceTheMaSe Mar 8, 2024
ce7b0fe
Compiler warnings - type conversion
RaceTheMaSe Mar 8, 2024
9510328
Compiler warnings - implicit conversion
RaceTheMaSe Mar 8, 2024
f8c1b06
Compiler warnings - maybe uninitialized
RaceTheMaSe Mar 8, 2024
2f7f874
Compiler warnings - compare unsigned to negative
RaceTheMaSe Mar 8, 2024
4f19894
Compiler warnings - memset non-trivial type
RaceTheMaSe Mar 8, 2024
76318ba
Compiler warnings - unreachable code
RaceTheMaSe Mar 8, 2024
1e38009
Compiler warnings - unreachable code (bugfix)
RaceTheMaSe Mar 8, 2024
1c8b39e
Compiler warnings - compare instead of assignment in asserts (bugfix)
RaceTheMaSe Mar 8, 2024
eadc0fc
Compiler warnings - scoped variables hides other (bugfix)
RaceTheMaSe Apr 11, 2024
dd60def
Compiler warnings - MinGW MSVC and macro redefinition
RaceTheMaSe Mar 8, 2024
516800b
Compiler warnings - constant expression in conditional statement
RaceTheMaSe Mar 8, 2024
74d576c
Compiler warnings - assign in conditional statement
RaceTheMaSe Mar 8, 2024
6a71593
Compiler warnings - suggest paranthesis
RaceTheMaSe Mar 8, 2024
1f104ca
Compiler warnings - implicit fallthrough
RaceTheMaSe Mar 8, 2024
eb97b50
Compiler warnings - unused return value
RaceTheMaSe Mar 8, 2024
ecadad6
Compiler warnings - useless const
RaceTheMaSe Mar 8, 2024
0ece71f
Compiler warnings - anonymous struct
RaceTheMaSe Mar 8, 2024
f185dc5
Compiler warnings - printf possible OOB write
RaceTheMaSe Mar 8, 2024
39c2af7
Compiler warnings - virtual functions not marked override
RaceTheMaSe Mar 8, 2024
81fe914
override to BT_OVERRIDE
RaceTheMaSe Mar 9, 2024
43176e9
Compiler warnings - zero as nullptr - NULL
RaceTheMaSe Mar 9, 2024
273c1f8
Compiler warnings - zero as nullptr - NULL - examples
RaceTheMaSe Mar 8, 2024
b460fd7
Compiler warnings - zero as nullptr - NULL - openvr
RaceTheMaSe Mar 8, 2024
9d0a502
Compiler warnings - shadow
RaceTheMaSe Mar 8, 2024
1be983a
Compiler warnings - switch default
RaceTheMaSe Mar 8, 2024
c1030e1
Compiler warnings - switch default without case statement
RaceTheMaSe Mar 8, 2024
8bf973a
Compiler warnings - array-parameter
RaceTheMaSe Mar 9, 2024
b2cde58
Compiler warnings - documentation
RaceTheMaSe Mar 8, 2024
26f1a1c
Compiler warnings - multiline comment
RaceTheMaSe Mar 8, 2024
c2d61b2
Compiler warnings - invalid utf8
RaceTheMaSe Mar 9, 2024
444cece
Compiler warnings - format
RaceTheMaSe Mar 8, 2024
2370237
Compiler warnings - format-overflow
RaceTheMaSe Mar 9, 2024
f2b838f
Compiler warnings - superfluous semicolon
RaceTheMaSe Mar 8, 2024
b19b368
Compiler warnings - comma at end of enum
RaceTheMaSe Mar 9, 2024
4f6cf88
Compiler warnings - comma at end of enum - openvr
RaceTheMaSe Mar 9, 2024
573adb6
Compiler warnings - newline at end of file
RaceTheMaSe Mar 9, 2024
fafb5e5
Compiler warnings - format specifier printf
RaceTheMaSe Mar 9, 2024
60f6204
Compiler warnings - multiline comment - gtest
RaceTheMaSe Mar 9, 2024
0bd1b90
Compiler warnings - type conversion - gtest
RaceTheMaSe Mar 9, 2024
d28e367
Compiler warnings - unused parameter - stb_truetype
RaceTheMaSe Mar 9, 2024
b09bb01
Compiler warnings - uninitialized members - stb_image
RaceTheMaSe Apr 11, 2024
4661e23
Compiler warnings - stb_truetype - refine macro for unused parameters
RaceTheMaSe Mar 9, 2024
edcb9a4
Compiler warnings - ignored loop variable (MSVC C4258)
RaceTheMaSe Apr 11, 2024
901c1ac
Compiler warnings - documentation-unknown-command
RaceTheMaSe Mar 9, 2024
5e77db9
Compiler error - M_PI undefined
RaceTheMaSe Mar 8, 2024
850590e
Compiler error - snprintf undefined
RaceTheMaSe Apr 11, 2024
ddb9656
MinGW compatibility
RaceTheMaSe Mar 8, 2024
e328adc
inverse square root - float only - newer version of GIMPACT has this …
RaceTheMaSe Mar 8, 2024
8914bfd
remove unnecessary overwrite of STBTT_malloc and _free
RaceTheMaSe Mar 8, 2024
9deea03
clang suggested bugfix
RaceTheMaSe Mar 9, 2024
78fc47b
documentation fix
RaceTheMaSe Mar 9, 2024
5bffd75
include files removed for C++98 mode compilation with GCC
RaceTheMaSe Mar 9, 2024
9fb78ec
unsolved - variadic args in macros
RaceTheMaSe Mar 8, 2024
e3e1df5
CMake - compile settings more pedantic build
RaceTheMaSe Apr 12, 2024
757487e
gitignore
RaceTheMaSe Apr 12, 2024
20068b9
Revert introduced error
RaceTheMaSe Jul 21, 2024
ed1cfab
Revert faulty unused and readd calls with potential side-effects
RaceTheMaSe Jul 23, 2024
da1eacf
CMake - pedantic build MSVC
RaceTheMaSe Jul 21, 2024
2b5b787
Compiler error - STB unused - MSVC compatible
RaceTheMaSe Jul 21, 2024
4e932d3
Compiler error - isfinite function
RaceTheMaSe Jul 24, 2024
87d30c9
Compiler error - cast between pointer-to-function and pointer-to-obje…
RaceTheMaSe Aug 8, 2024
3dcb03e
Compiler error - btSoftBody
RaceTheMaSe Aug 9, 2024
04c808b
Compiler error - undefined symbol - link error with static libraries
RaceTheMaSe Aug 9, 2024
77586f4
Compiler warnings - unsafe function pointer - MSVC compatible
RaceTheMaSe Jul 21, 2024
785579d
Compiler warnings - unsafe function pointer - Clang compatible
RaceTheMaSe Jul 21, 2024
49dd5f2
Compiler warnings - out of range value assigned
RaceTheMaSe Jul 21, 2024
ea24d94
Compiler warnings - virtual destructor
RaceTheMaSe Jul 21, 2024
e742ddb
Compiler warnings - unreachable code
RaceTheMaSe Jul 21, 2024
2926516
Compiler warnings - implicit conversion
RaceTheMaSe Aug 9, 2024
6b95ba6
Compiler warnings - implicit conversion - GTest
RaceTheMaSe Jul 21, 2024
1ae5d77
Compiler warnings - hides previous declaration
RaceTheMaSe Jul 22, 2024
7c9cd23
Compiler warnings - assign in conditional statement
RaceTheMaSe Jul 23, 2024
fc9df30
Compiler warnings - implicit conversion float types
RaceTheMaSe Aug 9, 2024
2e6e519
Compiler warnings - implicit conversion - no STB
RaceTheMaSe Jul 23, 2024
c54ecbe
Static analyzer - unused
RaceTheMaSe Jul 23, 2024
3179007
Static analyzer - unused result
RaceTheMaSe Aug 8, 2024
9fbcb78
Static analyzer - null dereference
RaceTheMaSe Jul 23, 2024
9b2df4e
Static analyzer - format string
RaceTheMaSe Jul 23, 2024
7173765
Static analyzer - uninitialized memory
RaceTheMaSe Jul 23, 2024
9c0eafb
Static analyzer - string terminate
RaceTheMaSe Jul 24, 2024
e73d751
Static analyzer - realloc
RaceTheMaSe Jul 24, 2024
ff470a2
Static analyzer - OOB access (bugfix)
RaceTheMaSe Aug 8, 2024
a104ffa
Static analyzer - memory leak (bugfix)
RaceTheMaSe Aug 8, 2024
828d80a
Static analyzer - use after free (bugfix)
RaceTheMaSe Aug 8, 2024
247beb1
Static analyzer - redundant statement (bugfix)
RaceTheMaSe Jul 24, 2024
946ce31
Static analyzer - redundant statement - unsolved
RaceTheMaSe Aug 8, 2024
c8df5ef
btScalar - div by zero (bugfix)
RaceTheMaSe Jul 21, 2024
cf4ef90
format-string unsure
RaceTheMaSe Jul 24, 2024
02a2e5c
Compiler warnings - implicit conversion - bool to unsigned int
RaceTheMaSe Dec 7, 2024
8ff09f0
Compiler warnings - unknown warning number MSVC
RaceTheMaSe Dec 7, 2024
723a304
Compiler warnings - implicit type conversion and truncation
RaceTheMaSe Dec 7, 2024
43f12da
Compiler warnings - buffer overrun (bugfix)
RaceTheMaSe Dec 10, 2024
e8d4d4e
Compiler warnings - mutual exclusion in assert (bugfix)
RaceTheMaSe Dec 10, 2024
54d4092
Compiler warnings - no function prototype given
RaceTheMaSe Dec 10, 2024
e76a0cc
Compiler warnings - possible null dereference, reading uninitialized …
RaceTheMaSe Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ CTestTestFile.cmake
.vscode/
.idea/
cmake-build-debug/
build-*/
68 changes: 68 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ cmake_policy(SET CMP0017 NEW)
#this line has to appear before 'PROJECT' in order to be able to disable incremental linking
SET(MSVC_INCREMENTAL_DEFAULT ON)

if(TOOLCHAIN_ROOT)
include(MinGW64.cmake)
endif()

PROJECT(BULLET_PHYSICS)
FILE (STRINGS "VERSION" BULLET_VERSION)

Expand Down Expand Up @@ -269,6 +273,70 @@ IF (BULLET2_USE_OPEN_MP_MULTITHREADING)
ENDIF (MSVC)
ENDIF (BULLET2_USE_OPEN_MP_MULTITHREADING)

set(CMAKE_CXX_STANDARD 98)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4005") # macro redefined
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4061") # enumerator 'value' in switch of enum 'type' is not handled explicitly
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4191") # unsafe conversion of function pointers
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4263 /wd4264 /wd4266") # virtual function override with same name and different arguments
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4464") # relative include paths
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4512 /wd4514 /wd4623 /wd4625 /wd4626 /wd5026 /wd5027") # implicitly deleted constructor, destructor, assignment operators
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4548") # expression before comma has no effect; expected expression with side-effect
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4668") # 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives'
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4710 /wd4711 /wd4714") # not inlined
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4820") # 'bytes' bytes padding added after construct 'member_name'
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996") # tr1 namespace deprecated
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5031") # pragma warning(pop): likely mismatch, popping warning state pushed in different file
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5039") # function': pointer or reference to potentially throwing function passed to extern C function under -EHc. Undefined behavior may occur if this function throws an exception.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5045") # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5105") # macro expansion producing 'defined' has undefined behavior
# enet
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4146") # unary minus operator applied to unsigned type, result still unsigned

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.10) # from MSVC 2017
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus,preprocessor /permissive-")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++14") # earliest c++ standard explicitly supported
endif()
# static analyzer:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /analyze:stacksize 65736") # static analyzer
# gtest:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd6326") # Potential comparison of a constant with another constant
ELSE()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-int-to-void-pointer-cast") # hellovr, SimpleSocket
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-int-to-pointer-cast") # hellovr, stb_image
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long") # C++98 has no long long
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros") # C++98 variadic macros
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers") # gtest, stb_image
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized") # gtest
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-attributes") # b3Int64 cl_long
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy") # GIMPACT
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing") # GIMPACT, btSoftBody, OpenCL
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow") # btAlignedObjectArray - placement new
ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-as-null-pointer-constant") # 0, NULL or nullptr
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy-with-user-provided-copy") # GIMPACT
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual") # exampleBrowser OpenGLGuiHelper and btDeformable*
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-null-pointer-subtraction") # btSoftBody
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof") # hellovr
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-parameter")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-but-set-variable")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-function")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-label")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-local-typedefs")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-variable")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-value")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused")

#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xanalyzer -fanalyzer") # static analyzer
ENDIF()

IF (BULLET2_USE_TBB_MULTITHREADING)
SET (BULLET2_TBB_INCLUDE_DIR "not found" CACHE PATH "Directory for Intel TBB includes.")
SET (BULLET2_TBB_LIB_DIR "not found" CACHE PATH "Directory for Intel TBB libraries.")
Expand Down
19 changes: 11 additions & 8 deletions Extras/ConvexDecomposition/ConvexBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool ConvexBuilder::isDuplicate(unsigned int i1, unsigned int i2, unsigned int i
return dcount == 3;
}

void ConvexBuilder::getMesh(const ConvexDecomposition::ConvexResult &cr, VertexLookup vc, UintVector &indices)
void ConvexBuilder::getMesh(const ConvexDecomposition::ConvexResult &cr, VertexLookup vc, UintVector & /*indices*/)
{
unsigned int *src = cr.mHullIndices;

Expand All @@ -93,6 +93,9 @@ void ConvexBuilder::getMesh(const ConvexDecomposition::ConvexResult &cr, VertexL
i1 = Vl_getIndex(vc, p1);
i2 = Vl_getIndex(vc, p2);
i3 = Vl_getIndex(vc, p3);
(void)i1;
(void)i2;
(void)i3;

#if 0
bool duplicate = false;
Expand Down Expand Up @@ -138,7 +141,7 @@ CHull *ConvexBuilder::canMerge(CHull *a, CHull *b)

unsigned int vcount = Vl_getVcount(vc);
const float *vertices = Vl_getVertices(vc);
unsigned int tcount = indices.size() / 3;
unsigned int tcount = (unsigned int)(indices.size() / 3);

//don't do anything if hull is empty
if (!tcount)
Expand Down Expand Up @@ -207,10 +210,10 @@ bool ConvexBuilder::combineHulls(void)
++i;
while (i != mChulls.size())
{
CHull *cr = mChulls[i];
if (cr != match)
CHull *ch = mChulls[i];
if (ch != match)
{
output.push_back(cr);
output.push_back(ch);
}
i++;
}
Expand Down Expand Up @@ -283,9 +286,9 @@ unsigned int ConvexBuilder::process(const ConvexDecomposition::DecompDesc &desc)
hdesc.SetHullFlag(ConvexDecomposition::QF_SKIN_WIDTH); // do skin width computation.
}

ConvexDecomposition::HullError ret = hl.CreateConvexHull(hdesc, result);
ConvexDecomposition::HullError retCreate = hl.CreateConvexHull(hdesc, result);

if (ret == ConvexDecomposition::QE_OK)
if (retCreate == ConvexDecomposition::QE_OK)
{
ConvexDecomposition::ConvexResult r(result.mNumOutputVertices, result.mOutputVertices, result.mNumFaces, result.mIndices);

Expand All @@ -311,7 +314,7 @@ unsigned int ConvexBuilder::process(const ConvexDecomposition::DecompDesc &desc)
delete cr;
}

ret = mChulls.size();
ret = (unsigned int)mChulls.size();

mChulls.clear();

Expand Down
16 changes: 8 additions & 8 deletions Extras/ConvexDecomposition/ConvexDecomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ void calcConvexDecomposition(unsigned int vcount,
// ok... here we recursively call
if (ifront.size())
{
unsigned int vcount = Vl_getVcount(vfront);
const float *vertices = Vl_getVertices(vfront);
unsigned int tcount = ifront.size() / 3;
unsigned int vertCount = Vl_getVcount(vfront);
const float *verts = Vl_getVertices(vfront);
unsigned int triCount = (unsigned int)(ifront.size() / 3);

calcConvexDecomposition(vcount, vertices, tcount, &ifront[0], callback, masterVolume, depth + 1);
calcConvexDecomposition(vertCount, verts, triCount, &ifront[0], callback, masterVolume, depth + 1);
}

ifront.clear();
Expand All @@ -331,11 +331,11 @@ void calcConvexDecomposition(unsigned int vcount,

if (iback.size())
{
unsigned int vcount = Vl_getVcount(vback);
const float *vertices = Vl_getVertices(vback);
unsigned int tcount = iback.size() / 3;
unsigned int vertCount = Vl_getVcount(vback);
const float *verts = Vl_getVertices(vback);
unsigned int triCount = (unsigned int)(iback.size() / 3);

calcConvexDecomposition(vcount, vertices, tcount, &iback[0], callback, masterVolume, depth + 1);
calcConvexDecomposition(vertCount, verts, triCount, &iback[0], callback, masterVolume, depth + 1);
}

iback.clear();
Expand Down
8 changes: 4 additions & 4 deletions Extras/ConvexDecomposition/ConvexDecomposition.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ class ConvexDecompInterface
{
public:
virtual ~ConvexDecompInterface(){};
virtual void ConvexDebugTri(const float *p1, const float *p2, const float *p3, unsigned int color){};
virtual void ConvexDebugPoint(const float *p, float dist, unsigned int color){};
virtual void ConvexDebugBound(const float *bmin, const float *bmax, unsigned int color){};
virtual void ConvexDebugOBB(const float *sides, const float *matrix, unsigned int color){};
virtual void ConvexDebugTri(const float * /*p1*/, const float * /*p2*/, const float * /*p3*/, unsigned int /*color*/){};
virtual void ConvexDebugPoint(const float * /*p*/, float /*dist*/, unsigned int /*color*/){};
virtual void ConvexDebugBound(const float * /*bmin*/, const float * /*bmax*/, unsigned int /*color*/){};
virtual void ConvexDebugOBB(const float * /*sides*/, const float * /*matrix*/, unsigned int /*color*/){};

virtual void ConvexDecompResult(ConvexResult &result) = 0;
};
Expand Down
Loading