Skip to content

Conversation

@meetrp
Copy link

@meetrp meetrp commented Oct 13, 2018

PROBLEM

[ 12%] Building C object tests/CMakeFiles/unity.dir/unity/src/unity.c.o
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:271:18: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
               ~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:271:37: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
                                 ~~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:271:45: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
                                            ^~~~ ~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:271:61: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
                                                          ~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:278:19: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number == 0.0f) UnityPrint("0");
               ~~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:289:35: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number < 100000.0f / 1e6f)  { number *= 1e6f; exponent -= 6; }
                      ~ ~~~~~~~~~~^~~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:289:56: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number < 100000.0f / 1e6f)  { number *= 1e6f; exponent -= 6; }
                                                    ~~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:290:25: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number < 100000.0f)         { number *= 10.0f; exponent--; }
                      ~ ^~~~~~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:290:56: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number < 100000.0f)         { number *= 10.0f; exponent--; }
                                                    ~~ ^~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:291:36: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number > 1000000.0f * 1e6f) { number /= 1e6f; exponent += 6; }
                      ~ ~~~~~~~~~~~^~~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:291:56: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number > 1000000.0f * 1e6f) { number /= 1e6f; exponent += 6; }
                                                    ~~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:292:25: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number > 1000000.0f)        { number /= 10.0f; exponent++; }
                      ~ ^~~~~~~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:292:56: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number > 1000000.0f)        { number /= 10.0f; exponent++; }
                                                    ~~ ^~~~~
13 warnings generated.

SOLUTION

As per documentation, in 'C', "The type of a floating literal is double unless explicitly specified by a suffix" Hence removed the 'suffices' from all the warning lines.
Also, the type of the variable number is 'double' so removing the suffices seem to make sense.

The compilation warnings are:

[ 12%] Building C object tests/CMakeFiles/unity.dir/unity/src/unity.c.o
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:271:18: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
               ~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:271:37: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
                                 ~~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:271:45: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
                                            ^~~~ ~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:271:61: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f))
                                                          ~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:278:19: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
    if (number == 0.0f) UnityPrint("0");
               ~~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:289:35: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number < 100000.0f / 1e6f)  { number *= 1e6f; exponent -= 6; }
                      ~ ~~~~~~~~~~^~~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:289:56: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number < 100000.0f / 1e6f)  { number *= 1e6f; exponent -= 6; }
                                                    ~~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:290:25: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number < 100000.0f)         { number *= 10.0f; exponent--; }
                      ~ ^~~~~~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:290:56: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number < 100000.0f)         { number *= 10.0f; exponent--; }
                                                    ~~ ^~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:291:36: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number > 1000000.0f * 1e6f) { number /= 1e6f; exponent += 6; }
                      ~ ~~~~~~~~~~~^~~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:291:56: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number > 1000000.0f * 1e6f) { number /= 1e6f; exponent += 6; }
                                                    ~~ ^~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:292:25: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number > 1000000.0f)        { number /= 10.0f; exponent++; }
                      ~ ^~~~~~~~~~
/Users/pkumar12/Code/GitHub/cJSON/tests/unity/src/unity.c:292:56: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
        while (number > 1000000.0f)        { number /= 10.0f; exponent++; }
                                                    ~~ ^~~~~
13 warnings generated.
@FSMaxB
Copy link
Collaborator

FSMaxB commented Oct 14, 2018

See #304

@FSMaxB FSMaxB closed this Oct 14, 2018
skyformat99 pushed a commit to skyformat99/cJSON-1 that referenced this pull request May 22, 2019
287e076 Post release
774da10 Merge pull request DaveGamble#296 from jlindgren90/master
629b86d Merge unity_setup.h into unity.h.
0914d80 Merge pull request DaveGamble#308 from codehearts/patch-1
5ee55fe Fix missing TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE
38c387b Merge pull request DaveGamble#304 from VLambret/master
17d4ea9 Color test results using ANSI escape codes
031b1ba Merge pull request DaveGamble#300 from jsalling/bugfix/greater-than
df78aad Make weak symbol usage more portable:
a7e8797 Fix link errors with MinGW.
94a3008 Update continuous integration to build 32-bit Unity
b119919 Add 64-bit comparison asserts
91bcbe1 Add 'greater/less or equal to' asserts on integers
8caade7 Fix bug in greater/less than asserts on unsigned int
1381a1a Update documentation.
2593c31 Allow suiteSetUp() and suiteTearDown() to be provided as normal C functions.
60def10 Update configuration docs

git-subtree-dir: tests/unity
git-subtree-split: 287e076962ec711cd2bdf08364a8df9ce51e106b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants