'-Werror=double-promotion' compilation warnings when including gtest.h #4351
Unanswered
dotanbrk
asked this question in
Community Help
Replies: 1 comment
-
The following patch solved the compilation warning, but i don't know if this the correct fix:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all.
I forked the gtest repository and compiled my test, using strict gcc compilation flags,
and there are compilation warnings/error when the test includes gtest headers.
Compiler: 9.4.0-1ubuntu1~20.04.1
In file included from /opt/third_party/googletest/googletest/include/gtest/gtest-matchers.h:49,
from /opt/third_party/googletest/googletest/include/gtest/internal/gtest-death-test-internal.h:47,
from /opt/third_party/googletest/googletest/include/gtest/gtest-death-test.h:43,
from /opt/third_party/googletest/googletest/include/gtest/gtest.h:64,
from /opt/third_party/googletest/googletest/src/gtest_main.cc:32:
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h: In instantiation of ‘int testing::internal::AppropriateResolution(FloatType) [with FloatType = float]’:
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:581:40: required from here
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:535:13: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
535 | if (val >= 100000.0) { // 100,000 to 999,999
| ~~~~^~~~~~~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:537:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
537 | } else if (val >= 10000.0) {
| ~~~~^~~~~~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:539:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
539 | } else if (val >= 1000.0) {
| ~~~~^~~~~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:541:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
541 | } else if (val >= 100.0) {
| ~~~~^~~~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:543:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
543 | } else if (val >= 10.0) {
| ~~~~^~~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:545:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
545 | } else if (val >= 1.0) {
| ~~~~^~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:547:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
547 | } else if (val >= 0.1) {
| ~~~~^~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:549:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
549 | } else if (val >= 0.01) {
| ~~~~^~~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:551:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
551 | } else if (val >= 0.001) {
| ~~~~^~~~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:553:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
553 | } else if (val >= 0.0001) {
| ~~~~^~~~~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:556:67: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
556 | if (static_cast(static_cast<int32_t>(val * mulfor6 + 0.5)) /
| ~~~~~~~~~~~~~~^~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:560:18: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
560 | } else if (val < 1e10) {
| ~~~~^~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:562:13: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
562 | if (val >= 1e9) { // 1,000,000,000 to 9,999,999,999
| ~~~~^~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:564:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
564 | } else if (val >= 1e8) { // 100,000,000 to 999,999,999
| ~~~~^~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:566:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
566 | } else if (val >= 1e7) { // 10,000,000 to 99,999,999
| ~~~~^~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:568:20: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
568 | } else if (val >= 1e6) { // 1,000,000 to 9,999,999
| ~~~~^~~~~~
/opt/third_party/googletest/googletest/include/gtest/gtest-printers.h:571:67: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
571 | if (static_cast(static_cast<int32_t>(val / divfor6 + 0.5)) *
I wander, did you ever notice those errors?
Thanks
Dotan
Beta Was this translation helpful? Give feedback.
All reactions