jk-jeon / dragonbox

Reference implementation of Dragonbox in C++
Apache License 2.0
588 stars 37 forks source link

MSVC: warning C4702: unreachable code #36

Closed seanmiddleditch closed 1 year ago

seanmiddleditch commented 1 year ago

The following error arises when compiling with MSVC (17.5.0 Preview 2.0) with /W4:

...\dragonbox-src\include\dragonbox\dragonbox.h(662): warning C4702: unreachable code

The line in for the warning is: https://github.com/jk-jeon/dragonbox/blob/4b195789bd4c995ea80ce5a65d6c145c70ae9a6b/include/dragonbox/dragonbox.h#L662

However, that isn't the real problem. The warning is actually triggered by the whole second if constexpr block at: https://github.com/jk-jeon/dragonbox/blob/4b195789bd4c995ea80ce5a65d6c145c70ae9a6b/include/dragonbox/dragonbox.h#L657

Changing that second if constexpr to else if constexpr resolves the warning.