You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Commit 7ed97b4 removed the defaulted operator= from vector types and replaced it with a non-default implementation. This causes GCC 8's -Wclass-memaccess (enabled by -Wall) to (rightfully) complain when you try to memcpy anything containing a i.e. a glm::vec3.
Simple example:
#include <glm/glm.hpp>
#include <cstring>
int main() {
glm::vec3 a = glm::vec3(0);
glm::vec3 b;
std::memcpy(&b, &a, sizeof(glm::vec3));
return b[0];
}
Output with -Wall:
test.cpp: In function ‘int main()’:
test.cpp:10:39: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘glm::vec3’ {aka ‘struct glm::vec<3, float, (glm::qualifier)0>’} with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
std::memcpy(&b, &a, sizeof(glm::vec3));
^
In file included from /home/dscharrer/pro/build/deps/glm-git/glm/vec3.hpp:8,
from /home/dscharrer/pro/build/deps/glm-git/glm/glm.hpp:107,
from test.cpp:1:
/home/dscharrer/pro/build/deps/glm-git/glm/detail/type_vec3.hpp:17:9: note: ‘glm::vec3’ {aka ‘struct glm::vec<3, float, (glm::qualifier)0>’} declared here
struct vec<3, T, Q>
^~~~~~~~~~~~
What was the problem with the previous implementation? It seems to work fine for vectors at least with GCC 4.8 and GCC 8 here.
The text was updated successfully, but these errors were encountered:
I was hiting some issues using defaulted contructors, const expressions and initializer lists with GCC...
Using memcpy with GLM types is a valid use case, I'll investigate how I can everything working together.
Commit 7ed97b4 removed the defaulted operator= from vector types and replaced it with a non-default implementation. This causes GCC 8's -Wclass-memaccess (enabled by -Wall) to (rightfully) complain when you try to memcpy anything containing a i.e. a glm::vec3.
Simple example:
Output with -Wall:
What was the problem with the previous implementation? It seems to work fine for vectors at least with GCC 4.8 and GCC 8 here.
The text was updated successfully, but these errors were encountered: