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

Fix uninitialized in constexpr warning #1264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JBurnWork
Copy link

Matrix multiplication functions that were recently marked as 'constexpr' in commit '1cc8e80e3ba140239196d9a4597a2ea8139a4aa5' can throw warnings about an "uninitialized variable 'Result' in constexpr function".

Fix the issue by removing 'Result' and returning the calculated matrix.
Only one matrix multiplication function per *.inl file used 'Result' as a variable, so this unifies how matrix multiplication functions are written.

@JBurnWork
Copy link
Author

In GCC 9.4.0, this solves the following:

<snip>/glm/glm/detail/type_mat4x4.hpp:13:9: note: ‘struct glm::mat<4, 4, float, glm::packed_highp>’ has no user-provided default constructor
   13 |  struct mat<4, 4, T, Q>
      |         ^~~~~~~~~~~~~~~
<snip>/glm/detail/type_mat4x4.hpp:35:49: note: constructor is not user-provided because it is explicitly defaulted in the class body
   35 |   GLM_DEFAULTED_DEFAULT_CTOR_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR;
      |                                                 ^~~
<snip>/glm/detail/type_vec4.hpp:68:14: note: and the implicitly-defined constructor does not initialize ‘float glm::vec<4, float, glm::packed_highp>::<unnamed union>::x’
   68 |    union { T x, r, s; };
      |              ^

@JBurnWork
Copy link
Author

When using an 'arm-poky-linux-gnueabi-g++' ARM GNU toolchain for the TI-DRA746 processor, the error is the following:

<snip>/glm/glm/./ext/../detail/type_mat4x4.inl: In instantiation of ???constexpr glm::mat<4, 4, T, Q> glm::operator*(const glm::mat<4, 4, T, Q>&, const glm::mat<4, 4, T, Q>&) [with T = float; glm::qualifier Q = (glm::qualifier)0u]???:
<snip>/glm/glm/./ext/../detail/type_mat4x4.inl:642:19: error: uninitialized variable ???Result??? in ???constexpr??? function
14:28:28    mat<4, 4, T, Q> Result;
14:28:28                    ^~~~~~
14:28:28 In file included from <snip>/glm/glm/./ext/matrix_double4x4.hpp:5:0,
14:28:28                  from <snip>/glm/glm/mat4x4.hpp:5,
<snip>/glm/glm/./ext/../detail/type_mat4x4.hpp:13:9: note: ???struct glm::mat<4, 4, float, (glm::qualifier)0u>??? has no user-provided default constructor
14:28:28   struct mat<4, 4, T, Q>
14:28:28          ^~~~~~~~~~~~~~~
<snip>/glm/glm/./ext/../detail/type_mat4x4.hpp:35:49: note: constructor is not user-provided because it is explicitly defaulted in the class body
14:28:28    GLM_DEFAULTED_DEFAULT_CTOR_DECL GLM_CONSTEXPR mat() GLM_DEFAULT_CTOR;
14:28:28                                                  ^~~
14:28:28 In file included from <snip>/glm/glm/./ext/../detail/type_mat4x4.hpp:6:0,
14:28:28                  from <snip>/glm/glm/./ext/matrix_double4x4.hpp:5,
14:28:28                  from <snip>/glm/glm/mat4x4.hpp:5,
<snip>/glm/glm/./ext/../detail/type_vec4.hpp:68:14: note: and the implicitly-defined constructor does not initialize ???float glm::vec<4, float, (glm::qualifier)0u>::<anonymous union>::x???
14:28:28     union { T x, r, s; };
14:28:28               ^

@DctrNoob
Copy link

+1 for this PR

@jdtech3
Copy link

jdtech3 commented Mar 22, 2024

+1 for this PR, this fixes compiling for Nios II as well.

@JBurnWork JBurnWork force-pushed the master branch 3 times, most recently from bce6732 to 3d4ef0a Compare March 22, 2024 14:12
Matrix multiplication functions that were recently marked as 'constexpr'
in commit '1cc8e80e3ba140239196d9a4597a2ea8139a4aa5' can throw warnings
about an "uninitialized variable 'Result' in constexpr function".

Change-Id: I95396da9ac8a6e0dd1b6ae4e782f75446cfa70a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants