Several float to int potential rounding errors/inconsistencies

Linus Torvalds torvalds at linux-foundation.org
Mon Mar 6 20:52:23 PST 2017


On Mon, Mar 6, 2017 at 8:50 PM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
> On Mon, Mar 6, 2017 at 8:27 PM, Linus Torvalds
> <torvalds at linux-foundation.org> wrote:
>>
>> Hmm. I guess there's "-Wfloat-conversion". It might cause excessive
>> warnings. I'll try.
>
> Ugh, yes. Mainly because it warns even about the "cast rint() to an
> integer" case:

If somebody wants to play with it, and (like me) doesn't know how to
add flags to the build due to CMake, here's what I did.

                Linus
-------------- next part --------------
 CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9998b76d..899c2af2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,6 +84,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
 	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ")
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-conversion")
 	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")


More information about the subsurface mailing list