GCC Compilation Warning Messages

Asked 2 years ago, Updated 2 years ago, 123 views

We are currently using GCC to modify the application.
I am using CMakeFiles created by my predecessor, so there are some things I don't understand.
This is not an error, but the following warning message appears:
If you know what kind of warning message and what to do, please let me know.

/home/user/util.h:114:53:warning:dereferencing type-punned pointer will break strict-alizing rules [-Wstrict-alizing]
     pc.r = reinterpret_cast<const float&>(r);

The environment is as follows:

Ubuntu 16.04
GCC

Thank you for your cooperation.

gcc

2022-09-30 14:59

1 Answers

When I search for it, it says that the cast is inappropriate, is that not true?

/home/user/util.h:114:53

Around line 114 of util.h?

pc.r=reinterpret_cast<const float&>(r);

This cast seems to be the problem.Do you use the compilation option "-Wstrict-alizing"?
I think that's why I pointed it out.


2022-09-30 14:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.