Browse Source

SceneGraph: work around -Wnon-virtual-dtor on GCC and Clang.

This warning isn't enabled by default by either -Wall or -Wextra, and
for a good reason. When I do that, it fires also for all uses of
Platform::Application, basically any subclass causes that warning to be
printed as well, even if given subclass is used just once, in an
anonymous namespace, and only through the MAGNUM_APPLICATION_MAIN()
macro. The only solution on Clang is to make such subclasses `final`,
but on GCC not even that helps and one is forced to really make the base
destructor virtual. Which doesn't achieve anything, only adds yet
another entry to the vtable.

So, in the SceneGraph it fixes one particular use case where the warning
was triggered, and since the fix isn't so invasive I'm fine with that.
For Platform I have no idea how an acceptable fix would look like, so I
hope nobody needs any of that anytime soon.

See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102168, especially
the part saying "This warning should not be used.".
pull/674/head
Vladimír Vondruš 1 year ago
parent
commit
cda3709af9
  1. 5
      doc/changelog.dox
  2. 2
      src/Magnum/SceneGraph/DualComplexTransformation.h
  3. 2
      src/Magnum/SceneGraph/DualQuaternionTransformation.h
  4. 2
      src/Magnum/SceneGraph/MatrixTransformation2D.h
  5. 2
      src/Magnum/SceneGraph/MatrixTransformation3D.h
  6. 2
      src/Magnum/SceneGraph/RigidMatrixTransformation2D.h
  7. 2
      src/Magnum/SceneGraph/RigidMatrixTransformation3D.h
  8. 2
      src/Magnum/SceneGraph/TranslationRotationScalingTransformation2D.h
  9. 2
      src/Magnum/SceneGraph/TranslationRotationScalingTransformation3D.h
  10. 2
      src/Magnum/SceneGraph/TranslationTransformation.h

5
doc/changelog.dox

@ -1167,6 +1167,11 @@ See also:
- Created a RPM package with a helper script for building (see - Created a RPM package with a helper script for building (see
[mosra/magnum#537](https://github.com/mosra/magnum/pull/537) and [mosra/magnum#537](https://github.com/mosra/magnum/pull/537) and
[mosra/magnum#650](https://github.com/mosra/magnum/pull/650)) [mosra/magnum#650](https://github.com/mosra/magnum/pull/650))
- Worked around a `-Wnon-virtual-dtor` warning on GCC and Clang in the
@ref SceneGraph library. The same warning (which is off by default) fires
also for any use of @ref Platform application classes, fixing that would
however only add warning suppression noise or force destructors to be
`virtual` for no reason, so it's not done there. See [mosra/magnum#665](https://github.com/mosra/magnum/issues/665).
@subsection changelog-latest-bugfixes Bug fixes @subsection changelog-latest-bugfixes Bug fixes

2
src/Magnum/SceneGraph/DualComplexTransformation.h

@ -185,6 +185,8 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
protected: protected:
/* Allow construction only from Object */ /* Allow construction only from Object */
explicit BasicDualComplexTransformation() = default; explicit BasicDualComplexTransformation() = default;
/* To silence -Wnon-virtual-dtor */
~BasicDualComplexTransformation() = default;
private: private:
void doResetTransformation() override final { resetTransformation(); } void doResetTransformation() override final { resetTransformation(); }

2
src/Magnum/SceneGraph/DualQuaternionTransformation.h

@ -209,6 +209,8 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
protected: protected:
/* Allow construction only from Object */ /* Allow construction only from Object */
explicit BasicDualQuaternionTransformation() = default; explicit BasicDualQuaternionTransformation() = default;
/* To silence -Wnon-virtual-dtor */
~BasicDualQuaternionTransformation() = default;
private: private:
void doResetTransformation() override final { resetTransformation(); } void doResetTransformation() override final { resetTransformation(); }

2
src/Magnum/SceneGraph/MatrixTransformation2D.h

@ -210,6 +210,8 @@ template<class T> class BasicMatrixTransformation2D: public AbstractBasicTransla
protected: protected:
/* Allow construction only from Object */ /* Allow construction only from Object */
explicit BasicMatrixTransformation2D() = default; explicit BasicMatrixTransformation2D() = default;
/* To silence -Wnon-virtual-dtor */
~BasicMatrixTransformation2D() = default;
private: private:
void doResetTransformation() override final { resetTransformation(); } void doResetTransformation() override final { resetTransformation(); }

2
src/Magnum/SceneGraph/MatrixTransformation3D.h

@ -283,6 +283,8 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
protected: protected:
/* Allow construction only from Object */ /* Allow construction only from Object */
explicit BasicMatrixTransformation3D() = default; explicit BasicMatrixTransformation3D() = default;
/* To silence -Wnon-virtual-dtor */
~BasicMatrixTransformation3D() = default;
private: private:
void doResetTransformation() override final { resetTransformation(); } void doResetTransformation() override final { resetTransformation(); }

2
src/Magnum/SceneGraph/RigidMatrixTransformation2D.h

@ -210,6 +210,8 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
protected: protected:
/* Allow construction only from Object */ /* Allow construction only from Object */
explicit BasicRigidMatrixTransformation2D() = default; explicit BasicRigidMatrixTransformation2D() = default;
/* To silence -Wnon-virtual-dtor */
~BasicRigidMatrixTransformation2D() = default;
private: private:
void doResetTransformation() override final { resetTransformation(); } void doResetTransformation() override final { resetTransformation(); }

2
src/Magnum/SceneGraph/RigidMatrixTransformation3D.h

@ -282,6 +282,8 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
protected: protected:
/* Allow construction only from Object */ /* Allow construction only from Object */
explicit BasicRigidMatrixTransformation3D() = default; explicit BasicRigidMatrixTransformation3D() = default;
/* To silence -Wnon-virtual-dtor */
~BasicRigidMatrixTransformation3D() = default;
private: private:
void doResetTransformation() override final { resetTransformation(); } void doResetTransformation() override final { resetTransformation(); }

2
src/Magnum/SceneGraph/TranslationRotationScalingTransformation2D.h

@ -206,6 +206,8 @@ template<class T> class BasicTranslationRotationScalingTransformation2D: public
protected: protected:
/* Allow construction only from Object */ /* Allow construction only from Object */
explicit BasicTranslationRotationScalingTransformation2D() = default; explicit BasicTranslationRotationScalingTransformation2D() = default;
/* To silence -Wnon-virtual-dtor */
~BasicTranslationRotationScalingTransformation2D() = default;
private: private:
void doResetTransformation() override final { resetTransformation(); } void doResetTransformation() override final { resetTransformation(); }

2
src/Magnum/SceneGraph/TranslationRotationScalingTransformation3D.h

@ -286,6 +286,8 @@ template<class T> class BasicTranslationRotationScalingTransformation3D: public
protected: protected:
/* Allow construction only from Object */ /* Allow construction only from Object */
explicit BasicTranslationRotationScalingTransformation3D() = default; explicit BasicTranslationRotationScalingTransformation3D() = default;
/* To silence -Wnon-virtual-dtor */
~BasicTranslationRotationScalingTransformation3D() = default;
private: private:
void doResetTransformation() override final { resetTransformation(); } void doResetTransformation() override final { resetTransformation(); }

2
src/Magnum/SceneGraph/TranslationTransformation.h

@ -112,6 +112,8 @@ class TranslationTransformation: public AbstractTranslation<dimensions, T, Trans
protected: protected:
/* Allow construction only from Object */ /* Allow construction only from Object */
explicit TranslationTransformation() = default; explicit TranslationTransformation() = default;
/* To silence -Wnon-virtual-dtor */
~TranslationTransformation() = default;
private: private:
void doResetTransformation() override final { resetTransformation(); } void doResetTransformation() override final { resetTransformation(); }

Loading…
Cancel
Save