RenderKit / oidn

Intel® Open Image Denoise library
https://www.openimagedenoise.org/
Apache License 2.0
1.77k stars 164 forks source link

Supress warning C4800 on MSVC 2015.3 #4

Closed Ybalrid closed 5 years ago

Ybalrid commented 5 years ago

Visual studio issue a (perfomance) warning when you shoehorn an int inside a bool. This patch fixes those warnings by explicitely checking the int values against 0, thus producing a bool. (I always thought C4800 was a bit silly to be honest)

This makes the code a tiny bit cleaner (state the bool conversion explicitly), while not actually changing the generated code:

https://godbolt.org/z/JANbo-

atafra commented 5 years ago

Did you actually get the warning when compiling OIDN? It should be disabled (/wd4800). Thanks!

Ybalrid commented 5 years ago

Yes, I've got that warning when building it. I generated a solution using CMake for Visual Studio 2015 Win64 - then proceded to do a Debug build.

4>primitive.cpp
2>c:\users\ybalrid\git\oidn\core\output_reorder.h(79): warning C4068: unknown pragma
2>C:\Users\ybalrid\git\oidn\core\autoencoder.cpp(47): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning)
2>C:\Users\ybalrid\git\oidn\core\autoencoder.cpp(49): warning C4800: 'int': forcing value to bool 'true' or 'false' (performance warning)
atafra commented 5 years ago

This warning was meant to be disabled but due to a bug in the CMake project, none of the warnings were disabled when compiled with Visual Studio. This will be soon fixed. Thanks!