doe300 / VC4C

Compiler for the VC4CL OpenCL implementation
MIT License
118 stars 37 forks source link

Fix narrowing error (double to float) #76

Closed long-long-float closed 6 years ago

long-long-float commented 6 years ago

In my environment (clang version 4.0.0-1ubuntu1~16.04.2 (tags/RELEASE_400/rc1)), cmake failed following error. This PR fixes it.

/***/test/test_stdlib.h:338:44: error: non-constant-expression cannot be narrowed from 
type 'double' to 'float' in
      initializer list [-Wc++11-narrowing]
                            addVector({}, 2, std::vector<float>{sqrt(36.0f), sqrt(25.0f + 1.0f), sqrt(16.0f + 4.0f)
, sqrt(9.0f + 9.0f)...
                                                                ^~~~~~~~~~~
/***/test/test_stdlib.h:338:44: note: insert an explicit cast to silence this issue
                            addVector({}, 2, std::vector<float>{sqrt(36.0f), sqrt(25.0f + 1.0f), sqrt(16.0f + 4.0f)
, sqrt(9.0f + 9.0f)...
                                                                ^~~~~~~~~~~
                                                                static_cast<float>( )
/***/test/test_stdlib.h:338:57: error: non-constant-expression cannot be narrowed from 
type 'double' to 'float' in
      initializer list [-Wc++11-narrowing]
                            addVector({}, 2, std::vector<float>{sqrt(36.0f), sqrt(25.0f + 1.0f), sqrt(16.0f + 4.0f)
, sqrt(9.0f + 9.0f)...
                                                                             ^~~~~~~~~~~~~~~~~~
/***/test/test_stdlib.h:338:57: note: insert an explicit cast to silence this issue
                            addVector({}, 2, std::vector<float>{sqrt(36.0f), sqrt(25.0f + 1.0f), sqrt(16.0f + 4.0f)
, sqrt(9.0f + 9.0f)...
                                                                             ^~~~~~~~~~~~~~~~~~
                                                                             static_cast<float>( )
... snip ...