Skip to content

Commit e0bc5f4

Browse files
committed
Enabled some more useful compiler warnings around fallthrough switches and missing virtual methods
Signed-off-by: Nick Avramoussis <4256455+Idclip@users.noreply.github.com>
1 parent 0cf46fb commit e0bc5f4

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

cmake/config/OpenVDBCXX.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ if(OPENVDB_CXX_STRICT)
178178
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wall>")
179179
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wextra>")
180180
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wconversion>")
181+
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wnon-virtual-dtor>")
182+
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wover-aligned>")
183+
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wimplicit-fallthrough>")
184+
add_compile_options("$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,9.3.0>>:-Wimplicit-fallthrough>")
181185
# Only check global constructors for libraries (we should really check for
182186
# executables too but gtest relies on these types of constructors for its
183187
# framework).
@@ -193,6 +197,7 @@ if(OPENVDB_CXX_STRICT)
193197
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wconversion>")
194198
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wdisabled-optimization>")
195199
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Woverloaded-virtual>")
200+
add_compile_options("$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wnon-virtual-dtor>")
196201
else()
197202
# NO OPENVDB_CXX_STRICT, suppress some warnings
198203
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")

openvdb/openvdb/tools/ParticlesToLevelSet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ struct ParticlesToLevelSet<SdfGridT, AttributeT, InterrupterT>::Raster
686686
const Vec3R Nrml = -V * invSpeed; // inverse normalized direction
687687
Vec3R P = P0; // local position of instance
688688
Real R = R0, d = 0; // local radius and length of trail
689-
for (size_t m = 0; run && d <= speed ; ++m) {
689+
while (run && d <= speed) {
690690
run = this->makeSphere(P, R, att, acc);
691691
P += 0.5 * delta * R * Nrml; // adaptive offset along inverse velocity direction
692692
d = (P - P0).length(); // current length of trail

openvdb/openvdb/unittest/TestFindActiveValues.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ TEST_F(TestFindActiveValues, testSphere2)
149149
openvdb::tools::FindActiveValues<openvdb::FloatTree> op(tree);
150150
auto bbox = openvdb::CoordBBox::createCube(openvdb::Coord(0), 1);
151151
//openvdb::util::CpuTimer timer("\nInscribed cube (class)");
152-
int count = 0;
152+
//int count = 0;
153153
while(op.noActiveValues(bbox)) {
154-
++count;
154+
//++count;
155155
bbox.expand(1);
156156
}
157157
//const double t = timer.stop();
@@ -165,10 +165,10 @@ TEST_F(TestFindActiveValues, testSphere2)
165165
{// find largest inscribed cube in index space containing NO active values
166166
auto bbox = openvdb::CoordBBox::createCube(openvdb::Coord(0), 1);
167167
//openvdb::util::CpuTimer timer("\nInscribed cube (func)");
168-
int count = 0;
168+
//int count = 0;
169169
while(!openvdb::tools::anyActiveValues(tree, bbox)) {
170170
bbox.expand(1);
171-
++count;
171+
//++count;
172172
}
173173
//const double t = timer.stop();
174174
//std::cerr << "Inscribed bbox = " << bbox << std::endl;

openvdb_cmd/vdb_ax/cli.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ inline void usage(std::ostream& os,
181181
struct ParamBase
182182
{
183183
ParamBase() = default;
184+
virtual ~ParamBase() = default;
184185
inline const std::vector<const char*>& opts() const { return mOpts; }
185186
inline const char* doc() const { return mDoc; }
186187
virtual void init(const char* arg, const uint32_t idx = 0) = 0;
@@ -198,6 +199,12 @@ struct BasicParam
198199
using CB = std::function<void(T&, const char*)>;
199200
BasicParam(T&& v) : mValue(std::move(v)) {}
200201
BasicParam(const T& v) : mValue(v) {}
202+
203+
BasicParam(const BasicParam&) = default;
204+
BasicParam(BasicParam&&) = default;
205+
BasicParam& operator=(const BasicParam&) = default;
206+
BasicParam& operator=(BasicParam&&) = default;
207+
201208
inline void set(const T& v) { mValue = v; }
202209
inline T& get() { return mValue; }
203210
inline const T& get() const { return mValue; }
@@ -212,6 +219,12 @@ struct BasicParam
212219
template <typename T>
213220
struct Param : public BasicParam<T>, ParamBase
214221
{
222+
~Param() override = default;
223+
Param(const Param&) = default;
224+
Param(Param&&) = default;
225+
Param& operator=(const Param&) = default;
226+
Param& operator=(Param&&) = default;
227+
215228
// CB1 callback passes the value to store
216229
// CB2 callback passed the value and the argument provided
217230
// CB3 callback passed the value, the argument provided and the index to

0 commit comments

Comments
 (0)