g-truc / glm

OpenGL Mathematics (GLM)
https://glm.g-truc.net
Other
9.1k stars 2.12k forks source link

Why `GLM_FORCE_CTOR_INIT` is not set by default when even matrix multiplication needs it? #1256

Closed nikitanodar closed 7 months ago

nikitanodar commented 7 months ago

Hello.

System: Ubuntu 20.04.6 Compiler: 9.4.0 GLM: version 1.0.0

This code throws a bunch of notes on gcc 9.4:

glm::mat4x4 const a{1.0};
glm::mat4x4 const b{1.0};

glm::mat4x4 const c{a * b};

It's strange because it's not an error or even a warning, and the code compiles even with warnings-as-errors option. Digging into the source I can see that the call function of struct mul4x4<T, Q, false> indeed has a default-constructed object mat<4, 4, T, Q> Result;. On a gcc10+ compiler it compiles without any notes.

Here's the link to try it live.

christophe-lunarg commented 7 months ago

Hi, I think it's historically because GLSL spec doesn't require the types to be initialize so as GLM tries to follow as closely that spec, GLM_FORCE_CTOR_INIT was added because it's convenient to have.

Thanks, Christophe