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
When GLM_FORCE_CTOR_INIT is not set, with C++11, it causes the default compiler-generated constructor to be used:
#if GLM_HAS_DEFAULTED_FUNCTIONS && GLM_CONFIG_CTOR_INIT == GLM_CTOR_INIT_DISABLE
define GLM_CONFIG_DEFAULTED_FUNCTIONS GLM_ENABLE
define GLM_DEFAULT = default
#else
define GLM_CONFIG_DEFAULTED_FUNCTIONS GLM_DISABLE
define GLM_DEFAULT
#endif
The compiler-generated constructor, as per the standard, will initialize all non-static members to their default value. Meaning for POD-types, they will be initialized to 0. The above defines (GLM_CONFIG_CTOR_INIT == GLM_CTOR_INIT_DISABLE) seem to assume that the default compiler-generated constructors don't initialize members, which is false.
When not using C++11, the user-defined constructors are used, and the variables will not be initialized to 0 unless GLM_FORCE_CTOR_INIT is set. With C++11, there is no way to turn off the initialization to 0 as is it.
A fix involving disabling defaulted functions can cause the copy constructor to also be user-defined, which can trigger new compilation issues with some CUDA functions passing glm objects to device kernels.
The text was updated successfully, but these errors were encountered:
Hello,
In my side, with C++11 or C++17 the initialization to 0 is turn off. But it's horrible because it use random values on stack, and the compiler does not detect that glm variables are not initialized.
I would prefered to have a glm library that initialize zero values by default, and propose to user the non-intialization version with a macro definition.
When GLM_FORCE_CTOR_INIT is not set, with C++11, it causes the default compiler-generated constructor to be used:
#if GLM_HAS_DEFAULTED_FUNCTIONS && GLM_CONFIG_CTOR_INIT == GLM_CTOR_INIT_DISABLE
define GLM_CONFIG_DEFAULTED_FUNCTIONS GLM_ENABLE
define GLM_DEFAULT = default
#else
define GLM_CONFIG_DEFAULTED_FUNCTIONS GLM_DISABLE
define GLM_DEFAULT
#endif
The compiler-generated constructor, as per the standard, will initialize all non-static members to their default value. Meaning for POD-types, they will be initialized to 0. The above defines (GLM_CONFIG_CTOR_INIT == GLM_CTOR_INIT_DISABLE) seem to assume that the default compiler-generated constructors don't initialize members, which is false.
When not using C++11, the user-defined constructors are used, and the variables will not be initialized to 0 unless GLM_FORCE_CTOR_INIT is set. With C++11, there is no way to turn off the initialization to 0 as is it.
A fix involving disabling defaulted functions can cause the copy constructor to also be user-defined, which can trigger new compilation issues with some CUDA functions passing glm objects to device kernels.
The text was updated successfully, but these errors were encountered: