Browse Source

GCC 4.4 compatibility: copy constructor ambiguity in matrix/vector classes.

Our own "copy" constructor accepting base class conflicts with the
default one, which for some reason gets added too. Newer versions don't
have this issue.
Vladimír Vondruš 13 years ago
parent
commit
1697f459a9
  1. 8
      src/Math/Test/MatrixTest.cpp
  2. 4
      src/Math/Test/Vector2Test.cpp
  3. 4
      src/Math/Test/Vector3Test.cpp
  4. 4
      src/Math/Test/Vector4Test.cpp
  5. 8
      src/Test/ArrayTest.cpp

8
src/Math/Test/MatrixTest.cpp

@ -108,10 +108,18 @@ MatrixTest::MatrixTest() {
}
void MatrixTest::construct() {
#ifndef CORRADE_GCC44_COMPATIBILITY
constexpr Matrix4 a = {Vector4(3.0f, 5.0f, 8.0f, -3.0f),
Vector4(4.5f, 4.0f, 7.0f, 2.0f),
Vector4(1.0f, 2.0f, 3.0f, -1.0f),
Vector4(7.9f, -1.0f, 8.0f, -1.5f)};
#else
/* Ambiguity with default copy constructor */
constexpr Matrix4 a(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
Vector4(4.5f, 4.0f, 7.0f, 2.0f),
Vector4(1.0f, 2.0f, 3.0f, -1.0f),
Vector4(7.9f, -1.0f, 8.0f, -1.5f));
#endif
CORRADE_COMPARE(a, Matrix4(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
Vector4(4.5f, 4.0f, 7.0f, 2.0f),
Vector4(1.0f, 2.0f, 3.0f, -1.0f),

4
src/Math/Test/Vector2Test.cpp

@ -96,7 +96,11 @@ Vector2Test::Vector2Test() {
}
void Vector2Test::construct() {
#ifndef CORRADE_GCC44_COMPATIBILITY
constexpr Vector2 a = {1.5f, 2.5f};
#else
constexpr Vector2 a(1.5f, 2.5f); /* Ambiguity with default copy constructor */
#endif
CORRADE_COMPARE(a, (Vector<2, Float>(1.5f, 2.5f)));
}

4
src/Math/Test/Vector3Test.cpp

@ -98,7 +98,11 @@ Vector3Test::Vector3Test() {
}
void Vector3Test::construct() {
#ifndef CORRADE_GCC44_COMPATIBILITY
constexpr Vector3 a = {1.0f, 2.5f, -3.0f};
#else
constexpr Vector3 a(1.0f, 2.5f, -3.0f); /* Ambiguity with default copy constructor */
#endif
CORRADE_COMPARE(a, (Vector<3, Float>(1.0f, 2.5f, -3.0f)));
}

4
src/Math/Test/Vector4Test.cpp

@ -95,7 +95,11 @@ Vector4Test::Vector4Test() {
}
void Vector4Test::construct() {
#ifndef CORRADE_GCC44_COMPATIBILITY
constexpr Vector4 a = {1.0f, -2.5f, 3.0f, 4.1f};
#else
constexpr Vector4 a(1.0f, -2.5f, 3.0f, 4.1f); /* Ambiguity with default copy constructor */
#endif
CORRADE_COMPARE(a, (Vector<4, Float>(1.0f, -2.5f, 3.0f, 4.1f)));
}

8
src/Test/ArrayTest.cpp

@ -61,13 +61,21 @@ void ArrayTest::construct() {
constexpr Array1D b = 5;
CORRADE_COMPARE(b, (Array<1, Int>(5)));
#ifndef CORRADE_GCC44_COMPATIBILITY
constexpr Array2D c = {5, 3};
#else
constexpr Array2D c(5, 3); /* Ambiguity with default copy constructor */
#endif
CORRADE_COMPARE(c, (Array<2, Int>(5, 3)));
constexpr Array2D c2 = 5;
CORRADE_COMPARE(c2, (Array<2, Int>(5, 5)));
#ifndef CORRADE_GCC44_COMPATIBILITY
constexpr Array3D d = {5, 3, -2};
#else
constexpr Array3D d(5, 3, -2); /* Ambiguity with default copy constructor */
#endif
CORRADE_COMPARE(d, (Array<3, Int>(5, 3, -2)));
constexpr Array3D d2 = 5;

Loading…
Cancel
Save