Fixed warnings with -Weverything

This commit is contained in:
Christophe Riccio 2017-08-08 14:59:11 +02:00
parent d799c282db
commit 97ac535144
4 changed files with 49 additions and 69 deletions

View File

@ -367,12 +367,12 @@ int test_operator_increment()
namespace heap namespace heap
{ {
class A struct A
{ {
float f; float f;
}; };
class B : public A struct B : public A
{ {
float g; float g;
glm::vec4 v; glm::vec4 v;
@ -380,11 +380,14 @@ namespace heap
int test() int test()
{ {
int Error(0); int Error = 0;
A* p = new B; A* p = new B;
p->f = 0.f;
delete p; delete p;
Error += sizeof(B) == (sizeof(glm::vec4) + sizeof(float) * 2) ? 0 : 1;
return Error; return Error;
} }
}//namespace heap }//namespace heap

View File

@ -191,8 +191,6 @@ namespace floatBitsToInt
float A = 1.0f; float A = 1.0f;
int B = glm::floatBitsToInt(A); int B = glm::floatBitsToInt(A);
float C = glm::intBitsToFloat(B); float C = glm::intBitsToFloat(B);
int D = *(int*)&A;
Error += B == D ? 0 : 1;
Error += A == C ? 0 : 1; Error += A == C ? 0 : 1;
} }
@ -200,8 +198,6 @@ namespace floatBitsToInt
glm::vec2 A(1.0f, 2.0f); glm::vec2 A(1.0f, 2.0f);
glm::ivec2 B = glm::floatBitsToInt(A); glm::ivec2 B = glm::floatBitsToInt(A);
glm::vec2 C = glm::intBitsToFloat(B); glm::vec2 C = glm::intBitsToFloat(B);
Error += B.x == *(int*)&(A.x) ? 0 : 1;
Error += B.y == *(int*)&(A.y) ? 0 : 1;
Error += A == C? 0 : 1; Error += A == C? 0 : 1;
} }
@ -209,9 +205,6 @@ namespace floatBitsToInt
glm::vec3 A(1.0f, 2.0f, 3.0f); glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::ivec3 B = glm::floatBitsToInt(A); glm::ivec3 B = glm::floatBitsToInt(A);
glm::vec3 C = glm::intBitsToFloat(B); glm::vec3 C = glm::intBitsToFloat(B);
Error += B.x == *(int*)&(A.x) ? 0 : 1;
Error += B.y == *(int*)&(A.y) ? 0 : 1;
Error += B.z == *(int*)&(A.z) ? 0 : 1;
Error += A == C? 0 : 1; Error += A == C? 0 : 1;
} }
@ -219,10 +212,6 @@ namespace floatBitsToInt
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::ivec4 B = glm::floatBitsToInt(A); glm::ivec4 B = glm::floatBitsToInt(A);
glm::vec4 C = glm::intBitsToFloat(B); glm::vec4 C = glm::intBitsToFloat(B);
Error += B.x == *(int*)&(A.x) ? 0 : 1;
Error += B.y == *(int*)&(A.y) ? 0 : 1;
Error += B.z == *(int*)&(A.z) ? 0 : 1;
Error += B.w == *(int*)&(A.w) ? 0 : 1;
Error += A == C? 0 : 1; Error += A == C? 0 : 1;
} }
@ -240,7 +229,6 @@ namespace floatBitsToUint
float A = 1.0f; float A = 1.0f;
glm::uint B = glm::floatBitsToUint(A); glm::uint B = glm::floatBitsToUint(A);
float C = glm::intBitsToFloat(B); float C = glm::intBitsToFloat(B);
Error += B == *(glm::uint*)&A ? 0 : 1;
Error += A == C? 0 : 1; Error += A == C? 0 : 1;
} }
@ -248,8 +236,6 @@ namespace floatBitsToUint
glm::vec2 A(1.0f, 2.0f); glm::vec2 A(1.0f, 2.0f);
glm::uvec2 B = glm::floatBitsToUint(A); glm::uvec2 B = glm::floatBitsToUint(A);
glm::vec2 C = glm::uintBitsToFloat(B); glm::vec2 C = glm::uintBitsToFloat(B);
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
Error += A == C ? 0 : 1; Error += A == C ? 0 : 1;
} }
@ -257,9 +243,6 @@ namespace floatBitsToUint
glm::vec3 A(1.0f, 2.0f, 3.0f); glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::uvec3 B = glm::floatBitsToUint(A); glm::uvec3 B = glm::floatBitsToUint(A);
glm::vec3 C = glm::uintBitsToFloat(B); glm::vec3 C = glm::uintBitsToFloat(B);
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
Error += A == C? 0 : 1; Error += A == C? 0 : 1;
} }
@ -267,10 +250,6 @@ namespace floatBitsToUint
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::uvec4 B = glm::floatBitsToUint(A); glm::uvec4 B = glm::floatBitsToUint(A);
glm::vec4 C = glm::uintBitsToFloat(B); glm::vec4 C = glm::uintBitsToFloat(B);
Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
Error += B.w == *(glm::uint*)&(A.w) ? 0 : 1;
Error += A == C? 0 : 1; Error += A == C? 0 : 1;
} }
@ -683,70 +662,70 @@ namespace roundEven
{ {
float A = glm::roundEven(0.0f); float A = glm::roundEven(0.0f);
Error += A == 0.0f ? 0 : 1; Error += glm::epsilonEqual(A, 0.0f, glm::epsilon<float>()) ? 0 : 1;
float B = glm::roundEven(0.5f); float B = glm::roundEven(0.5f);
Error += B == 0.0f ? 0 : 1; Error += glm::epsilonEqual(B, 0.0f, glm::epsilon<float>()) ? 0 : 1;
float C = glm::roundEven(1.0f); float C = glm::roundEven(1.0f);
Error += C == 1.0f ? 0 : 1; Error += glm::epsilonEqual(C, 1.0f, glm::epsilon<float>()) ? 0 : 1;
float D = glm::roundEven(0.1f); float D = glm::roundEven(0.1f);
Error += D == 0.0f ? 0 : 1; Error += glm::epsilonEqual(D, 0.0f, glm::epsilon<float>()) ? 0 : 1;
float E = glm::roundEven(0.9f); float E = glm::roundEven(0.9f);
Error += E == 1.0f ? 0 : 1; Error += glm::epsilonEqual(E, 1.0f, glm::epsilon<float>()) ? 0 : 1;
float F = glm::roundEven(1.5f); float F = glm::roundEven(1.5f);
Error += F == 2.0f ? 0 : 1; Error += glm::epsilonEqual(F, 2.0f, glm::epsilon<float>()) ? 0 : 1;
float G = glm::roundEven(1.9f); float G = glm::roundEven(1.9f);
Error += G == 2.0f ? 0 : 1; Error += glm::epsilonEqual(G, 2.0f, glm::epsilon<float>()) ? 0 : 1;
} }
{ {
float A = glm::roundEven(-0.0f); float A = glm::roundEven(-0.0f);
Error += A == 0.0f ? 0 : 1; Error += glm::epsilonEqual(A, 0.0f, glm::epsilon<float>()) ? 0 : 1;
float B = glm::roundEven(-0.5f); float B = glm::roundEven(-0.5f);
Error += B == -0.0f ? 0 : 1; Error += glm::epsilonEqual(B, -0.0f, glm::epsilon<float>()) ? 0 : 1;
float C = glm::roundEven(-1.0f); float C = glm::roundEven(-1.0f);
Error += C == -1.0f ? 0 : 1; Error += glm::epsilonEqual(C, -1.0f, glm::epsilon<float>()) ? 0 : 1;
float D = glm::roundEven(-0.1f); float D = glm::roundEven(-0.1f);
Error += D == 0.0f ? 0 : 1; Error += glm::epsilonEqual(D, 0.0f, glm::epsilon<float>()) ? 0 : 1;
float E = glm::roundEven(-0.9f); float E = glm::roundEven(-0.9f);
Error += E == -1.0f ? 0 : 1; Error += glm::epsilonEqual(E, -1.0f, glm::epsilon<float>()) ? 0 : 1;
float F = glm::roundEven(-1.5f); float F = glm::roundEven(-1.5f);
Error += F == -2.0f ? 0 : 1; Error += glm::epsilonEqual(F, -2.0f, glm::epsilon<float>()) ? 0 : 1;
float G = glm::roundEven(-1.9f); float G = glm::roundEven(-1.9f);
Error += G == -2.0f ? 0 : 1; Error += glm::epsilonEqual(G, -2.0f, glm::epsilon<float>()) ? 0 : 1;
} }
{ {
float A = glm::roundEven(1.5f); float A = glm::roundEven(1.5f);
Error += A == 2.0f ? 0 : 1; Error += glm::epsilonEqual(A, 2.0f, glm::epsilon<float>()) ? 0 : 1;
float B = glm::roundEven(2.5f); float B = glm::roundEven(2.5f);
Error += B == 2.0f ? 0 : 1; Error += glm::epsilonEqual(B, 2.0f, glm::epsilon<float>()) ? 0 : 1;
float C = glm::roundEven(3.5f); float C = glm::roundEven(3.5f);
Error += C == 4.0f ? 0 : 1; Error += glm::epsilonEqual(C, 4.0f, glm::epsilon<float>()) ? 0 : 1;
float D = glm::roundEven(4.5f); float D = glm::roundEven(4.5f);
Error += D == 4.0f ? 0 : 1; Error += glm::epsilonEqual(D, 4.0f, glm::epsilon<float>()) ? 0 : 1;
float E = glm::roundEven(5.5f); float E = glm::roundEven(5.5f);
Error += E == 6.0f ? 0 : 1; Error += glm::epsilonEqual(E, 6.0f, glm::epsilon<float>()) ? 0 : 1;
float F = glm::roundEven(6.5f); float F = glm::roundEven(6.5f);
Error += F == 6.0f ? 0 : 1; Error += glm::epsilonEqual(F, 6.0f, glm::epsilon<float>()) ? 0 : 1;
float G = glm::roundEven(7.5f); float G = glm::roundEven(7.5f);
Error += G == 8.0f ? 0 : 1; Error += glm::epsilonEqual(G, 8.0f, glm::epsilon<float>()) ? 0 : 1;
} }
{ {
float A = glm::roundEven(-1.5f); float A = glm::roundEven(-1.5f);
Error += A == -2.0f ? 0 : 1; Error += glm::epsilonEqual(A, -2.0f, glm::epsilon<float>()) ? 0 : 1;
float B = glm::roundEven(-2.5f); float B = glm::roundEven(-2.5f);
Error += B == -2.0f ? 0 : 1; Error += glm::epsilonEqual(B, -2.0f, glm::epsilon<float>()) ? 0 : 1;
float C = glm::roundEven(-3.5f); float C = glm::roundEven(-3.5f);
Error += C == -4.0f ? 0 : 1; Error += glm::epsilonEqual(C, -4.0f, glm::epsilon<float>()) ? 0 : 1;
float D = glm::roundEven(-4.5f); float D = glm::roundEven(-4.5f);
Error += D == -4.0f ? 0 : 1; Error += glm::epsilonEqual(D, -4.0f, glm::epsilon<float>()) ? 0 : 1;
float E = glm::roundEven(-5.5f); float E = glm::roundEven(-5.5f);
Error += E == -6.0f ? 0 : 1; Error += glm::epsilonEqual(E, -6.0f, glm::epsilon<float>()) ? 0 : 1;
float F = glm::roundEven(-6.5f); float F = glm::roundEven(-6.5f);
Error += F == -6.0f ? 0 : 1; Error += glm::epsilonEqual(F, -6.0f, glm::epsilon<float>()) ? 0 : 1;
float G = glm::roundEven(-7.5f); float G = glm::roundEven(-7.5f);
Error += G == -8.0f ? 0 : 1; Error += glm::epsilonEqual(G, -8.0f, glm::epsilon<float>()) ? 0 : 1;
} }
return Error; return Error;

View File

@ -3,8 +3,8 @@
#include <glm/gtc/vec1.hpp> #include <glm/gtc/vec1.hpp>
#include <vector> #include <vector>
static glm::vec1 v1; static glm::vec1 g1;
static glm::vec1 v2(1); static glm::vec1 g2(1);
int test_vec1_operators() int test_vec1_operators()
{ {

View File

@ -1,4 +1,5 @@
#define GLM_FORCE_SWIZZLE #define GLM_FORCE_SWIZZLE
#include <glm/gtc/epsilon.hpp>
#include <glm/vector_relational.hpp> #include <glm/vector_relational.hpp>
#include <glm/vec2.hpp> #include <glm/vec2.hpp>
#include <vector> #include <vector>
@ -25,8 +26,8 @@ int test_vec2_operators()
glm::vec2 A(1.0f); glm::vec2 A(1.0f);
glm::vec2 C = A + 1.0f; glm::vec2 C = A + 1.0f;
A += 1.0f; A += 1.0f;
Error += A.x == 2.0f && A.y == 2.0f ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, glm::vec2(2.0f), glm::epsilon<float>())) ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
} }
{ {
@ -34,16 +35,16 @@ int test_vec2_operators()
glm::vec2 B(2.0f,-1.0f); glm::vec2 B(2.0f,-1.0f);
glm::vec2 C = A + B; glm::vec2 C = A + B;
A += B; A += B;
Error += A.x == 3.0f && A.y == 0.0f ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, glm::vec2(3.0f, 0.0f), glm::epsilon<float>())) ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
} }
{ {
glm::vec2 A(1.0f); glm::vec2 A(1.0f);
glm::vec2 C = A - 1.0f; glm::vec2 C = A - 1.0f;
A -= 1.0f; A -= 1.0f;
Error += A.x == 0.0f && A.y == 0.0f ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, glm::vec2(0.0f), glm::epsilon<float>())) ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
} }
{ {
@ -51,16 +52,16 @@ int test_vec2_operators()
glm::vec2 B(2.0f,-1.0f); glm::vec2 B(2.0f,-1.0f);
glm::vec2 C = A - B; glm::vec2 C = A - B;
A -= B; A -= B;
Error += A.x == -1.0f && A.y == 2.0f ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, glm::vec2(-1.0f, 2.0f), glm::epsilon<float>())) ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
} }
{ {
glm::vec2 A(1.0f); glm::vec2 A(1.0f);
glm::vec2 C = A * 2.0f; glm::vec2 C = A * 2.0f;
A *= 2.0f; A *= 2.0f;
Error += A.x == 2.0f && A.y == 2.0f ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, glm::vec2(2.0f), glm::epsilon<float>())) ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
} }
{ {
@ -68,8 +69,8 @@ int test_vec2_operators()
glm::vec2 B(2.0f); glm::vec2 B(2.0f);
glm::vec2 C = A / B; glm::vec2 C = A / B;
A /= B; A /= B;
Error += A.x == 1.0f && A.y == 1.0f ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, glm::vec2(1.0f), glm::epsilon<float>())) ? 0 : 1;
Error += A.x == C.x && A.y == C.y ? 0 : 1; Error += glm::all(glm::epsilonEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
} }
{ {
@ -311,9 +312,6 @@ int main()
{ {
int Error = 0; int Error = 0;
glm::vec2 v;
assert(v.length() == 2);
Error += test_vec2_size(); Error += test_vec2_size();
Error += test_vec2_ctor(); Error += test_vec2_ctor();
Error += test_vec2_operators(); Error += test_vec2_operators();