Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile with GLM on Ubuntu, using Clang++ and C++11 due to errors #646

Closed
AndyEsser opened this issue Jun 29, 2017 · 5 comments
Closed

Comments

@AndyEsser
Copy link

I'm working on an OpenGL graphics display project, and using GLM as the mathematics library to save me a world of pain. I've used GLM previously and thing it's fantastic. However I'm not able to compile my project currently after trying to include GLM.

I am having a number of errors being thrown about reinterpret cast, or old style casts. I am compiling with Warnings treated as Errors due to the nature of the project as well as a number of other strict compilation flags. Below is the compilation output, and the command line invocation of clang++. I have also included a minimal project zipped up that demonstrates this issue.

Ubuntu 17.04
Clang++ 4.0.0-1ubuntu1

clang++ src/*.cpp -I include/ -o output -g -Weverything -Wpedantic -Werror -Wno-padded -Wno-c++98-compat -Wno-documentation -std=c++11

In file included from src/main.cpp:1: In file included from include/main.hpp:3: In file included from include/glm/glm.hpp:71: In file included from include/glm/detail/../mat2x2.hpp:6: In file included from include/glm/detail/type_mat2x2.hpp:182: In file included from include/glm/detail/type_mat2x2.inl:4: In file included from include/glm/detail/func_matrix.hpp:149: In file included from include/glm/detail/func_matrix.inl:4: In file included from include/glm/detail/../geometric.hpp:6: In file included from include/glm/detail/func_geometric.hpp:113: In file included from include/glm/detail/func_geometric.inl:5: In file included from include/glm/detail/func_common.hpp:426: include/glm/detail/func_common.inl:699:10: error: reinterpret_cast from 'float' to 'int &' has undefined behavior [-Werror,-Wundefined-reinterpret-cast] return reinterpret_cast<int&>(const_cast<float&>(v)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/glm/detail/func_common.inl:710:10: error: reinterpret_cast from 'float' to 'unsigned int &' has undefined behavior [-Werror,-Wundefined-reinterpret-cast] return reinterpret_cast<uint&>(const_cast<float&>(v)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/glm/detail/func_common.inl:721:10: error: reinterpret_cast from 'int' to 'float &' has undefined behavior [-Werror,-Wundefined-reinterpret-cast] return reinterpret_cast<float&>(const_cast<int&>(v)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/glm/detail/func_common.inl:732:10: error: reinterpret_cast from 'uint' (aka 'unsigned int') to 'float &' has undefined behavior [-Werror,-Wundefined-reinterpret-cast] return reinterpret_cast<float&>(const_cast<uint&>(v)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from src/main.cpp:1: In file included from include/main.hpp:3: In file included from include/glm/glm.hpp:71: In file included from include/glm/detail/../mat2x2.hpp:6: In file included from include/glm/detail/type_mat2x2.hpp:182: In file included from include/glm/detail/type_mat2x2.inl:4: In file included from include/glm/detail/func_matrix.hpp:149: In file included from include/glm/detail/func_matrix.inl:4: In file included from include/glm/detail/../geometric.hpp:6: In file included from include/glm/detail/func_geometric.hpp:113: In file included from include/glm/detail/func_geometric.inl:5: In file included from include/glm/detail/func_common.hpp:426: In file included from include/glm/detail/func_common.inl:848: In file included from include/glm/detail/func_common_simd.inl:6: include/glm/detail/../simd/common.h:115:57: error: implicit conversion changes signedness: 'unsigned int' to 'int' [-Werror,-Wsign-conversion] glm_vec4 const sgn0 = _mm_castsi128_ps(_mm_set1_epi32(0x80000000)); ~~~~~~~~~~~~~~ ^~~~~~~~~~ include/glm/detail/../simd/common.h:147:56: error: implicit conversion changes signedness: 'unsigned int' to 'int' [-Werror,-Wsign-conversion] glm_vec4 const sgn0 = _mm_castsi128_ps(_mm_set1_epi32(0x80000000)); ~~~~~~~~~~~~~~ ^~~~~~~~~~ include/glm/detail/../simd/common.h:223:38: error: implicit conversion changes signedness: 'unsigned int' to 'int' [-Werror,-Wsign-conversion] glm_ivec4 const t3 = _mm_set1_epi32(0xFF000000); // exponent mask ~~~~~~~~~~~~~~ ^~~~~~~~~~ include/glm/detail/../simd/common.h:237:61: error: implicit conversion changes signedness: 'unsigned int' to 'int' [-Werror,-Wsign-conversion] return _mm_castsi128_ps(_mm_cmpeq_epi32(t2, _mm_set1_epi32(0xFF000000))); // exponent is all 1s, fraction is 0 ~~~~~~~~~~~~~~ ^~~~~~~~~~ In file included from src/main.cpp:1: In file included from include/main.hpp:3: In file included from include/glm/glm.hpp:71: In file included from include/glm/detail/../mat2x2.hpp:6: In file included from include/glm/detail/type_mat2x2.hpp:182: In file included from include/glm/detail/type_mat2x2.inl:4: In file included from include/glm/detail/func_matrix.hpp:149: In file included from include/glm/detail/func_matrix.inl:4: In file included from include/glm/detail/../geometric.hpp:6: In file included from include/glm/detail/func_geometric.hpp:113: In file included from include/glm/detail/func_geometric.inl:5: In file included from include/glm/detail/func_common.hpp:426: In file included from include/glm/detail/func_common.inl:848: include/glm/detail/func_common_simd.inl:194:40: error: use of old-style cast [-Werror,-Wold-style-cast] __m128i const Load = _mm_set_epi32(-(int)a.w, -(int)a.z, -(int)a.y, -(int)a.x); ^ ~~~ include/glm/detail/func_common_simd.inl:194:51: error: use of old-style cast [-Werror,-Wold-style-cast] __m128i const Load = _mm_set_epi32(-(int)a.w, -(int)a.z, -(int)a.y, -(int)a.x); ^ ~~~ include/glm/detail/func_common_simd.inl:194:62: error: use of old-style cast [-Werror,-Wold-style-cast] __m128i const Load = _mm_set_epi32(-(int)a.w, -(int)a.z, -(int)a.y, -(int)a.x); ^ ~~~ include/glm/detail/func_common_simd.inl:194:73: error: use of old-style cast [-Werror,-Wold-style-cast] __m128i const Load = _mm_set_epi32(-(int)a.w, -(int)a.z, -(int)a.y, -(int)a.x); ^ ~~~ In file included from src/main.cpp:1: In file included from include/main.hpp:3: In file included from include/glm/glm.hpp:71: In file included from include/glm/detail/../mat2x2.hpp:6: In file included from include/glm/detail/type_mat2x2.hpp:182: In file included from include/glm/detail/type_mat2x2.inl:4: In file included from include/glm/detail/func_matrix.hpp:149: In file included from include/glm/detail/func_matrix.inl:399: include/glm/detail/func_matrix_simd.inl:22:6: error: use of old-style cast [-Werror,-Wold-style-cast] *(glm_vec4 const (*)[4])&x[0].data, ^ ~~~~~~~~~~ include/glm/detail/func_matrix_simd.inl:23:6: error: use of old-style cast [-Werror,-Wold-style-cast] *(glm_vec4 const (*)[4])&y[0].data, ^ ~~~~~~~~~~ include/glm/detail/func_matrix_simd.inl:24:6: error: use of old-style cast [-Werror,-Wold-style-cast] *(glm_vec4(*)[4])&result[0].data); ^ ~~~~~~~~~~~~~~~ include/glm/detail/func_matrix_simd.inl:36:6: error: use of old-style cast [-Werror,-Wold-style-cast] *(glm_vec4 const (*)[4])&m[0].data, ^ ~~~~~~~~~~ include/glm/detail/func_matrix_simd.inl:37:6: error: use of old-style cast [-Werror,-Wold-style-cast] *(glm_vec4(*)[4])&result[0].data); ^ ~~~~~~~~~~~~~~~ include/glm/detail/func_matrix_simd.inl:67:42: error: dereference of type '__m128 (*)[4]' that was reinterpret_cast from type 'typename detail::storage<float, sizeof(float) * 4, detail::is_aligned<(precision)5U>::value>::type *' (aka '__m128 *') has undefined behavior [-Werror,-Wundefined-reinterpret-cast] glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&m[0].data)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/glm/detail/func_matrix_simd.inl:75:42: error: dereference of type '__m128 (*)[4]' that was reinterpret_cast from type 'typename detail::storage<float, sizeof(float) * 4, detail::is_aligned<(precision)4U>::value>::type *' (aka '__m128 *') has undefined behavior [-Werror,-Wundefined-reinterpret-cast] glm_mat4_outerProduct(c.data, r.data, *reinterpret_cast<__m128(*)[4]>(&m[0].data)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. makefile:11: recipe for target 'build' failed make: *** [build] Error 1

glm-issue.tar.gz

@Groovounet
Copy link
Member

Hi,
Could you #define GLM_FORCE_MESSAGES before including GLM, build, and report here what GLM says?
Thanks!

@Groovounet Groovounet self-assigned this Jul 7, 2017
@Groovounet Groovounet added this to the GLM 0.9.9 milestone Jul 7, 2017
@AndyEsser
Copy link
Author

AndyEsser commented Jul 10, 2017

Hi,

Apologies for the slow response.

I have #define'd GLM_FORCE_MESSAGES before the include and rebuilt (I've done this on the ZIP file project I included to avoid any extra issues being dragged in). Below is the output:

GLM: Linux platform detected
GLM: version 0.9.8.4
GLM: Clang compiler detected
GLM: 64 bits model
GLM: SSE2 instruction set
GLM: C++11
GLM: Swizzling operators disabled, #define GLM_SWIZZLE to enable swizzle operators
GLM: Depth clip space: negative one to one
GLM: Coordinate system: right handed
GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification
GLM: Core library included

Edited for readability

@Groovounet
Copy link
Member

Hi,

I think the issue is that these arguments -g -Weverything -Wpedantic -Werror -Wno-padded -Wno-c++98-compat -Wno-documentation -std=c++11 are just way too strict for GLM.

Thanks for reporting,
Christophe

@AndyEsser
Copy link
Author

AndyEsser commented Jul 24, 2017

Many thanks for even bothering to take a look at it, it's much appreciated :).

Unfortunately for this project I'll have to ditch GLM then and roll my own. I shall continue using GLM for my other less strict projects, many thanks

@Groovounet
Copy link
Member

A lot of warnings has been resolved in master branch. Still quite a few warnings explicitly ignored in the CMakeLists.

Thanks,
Christophe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants