MATH: Add workaround for MSVC 2015 compiler bug (C2248)

At least MSVC 2015 (14.0.25420.01 Update 3) will hit a C2248 compiler
error.  Quoting @lephilousophe, "It looks like a bug. It tries to
generate a move constructor but it believes it can't access the base
constructor, although the constructor it creates is in a child class,
while the MatrixBase constructor is protected."

Since MSVC 2015 is still able to compile most of the engines and
components (not all of them, though), having a local hack for it
seems reasonable...
This commit is contained in:
Donovan Watteau
2025-10-05 19:51:31 +02:00
parent 2e9b0f183a
commit 4dea9d9782
2 changed files with 13 additions and 0 deletions
+9
View File
@@ -142,12 +142,17 @@ public:
Matrix<rows, cols> &operator/=(float factor);
Matrix<rows, cols> &operator/=(const Matrix<rows, cols> &m);
#if defined(_MSC_VER) && _MSC_VER < 1910 // HACK: C2248 bug in MSVC 2015
public:
#else
protected:
#endif
constexpr MatrixBase() = default;
MatrixBase(const float *data);
MatrixBase(const MatrixBase<rows, cols> &m);
MatrixBase &operator=(const MatrixBase<rows, cols> &m);
protected:
inline const Matrix<rows, cols> &getThis() const {
return *static_cast<const Matrix<rows, cols> *>(this); }
inline Matrix<rows, cols> &getThis() {
@@ -163,7 +168,11 @@ private:
*/
template<int r, int c>
class MatrixType : public MatrixBase<r, c> {
#if defined(_MSC_VER) && _MSC_VER < 1910 // HACK: C2248 bug in MSVC 2015
public:
#else
protected:
#endif
constexpr MatrixType() : MatrixBase<r, c>() { }
MatrixType(const float *data) : MatrixBase<r, c>(data) { }
MatrixType(const MatrixBase<r, c> &m) : MatrixBase<r, c>(m) { }
+4
View File
@@ -57,7 +57,11 @@ public:
*/
void readFromStream(Common::ReadStream *stream);
#if defined(_MSC_VER) && _MSC_VER < 1910 // HACK: C2248 bug in MSVC 2015
public:
#else
protected:
#endif
MatrixType() : MatrixBase<dim, 1>() { }
MatrixType(const float *data) : MatrixBase<dim, 1>(data) { }
MatrixType(const MatrixBase<dim, 1> &m) : MatrixBase<dim, 1>(m) { }