1

In this example I want MSVC to emit a warning:

auto func(float f) -> int {
  if(f) { return 654321;} // true if f != 0.0F
  else { return 123456; }
}

So that I'm forced to write:

auto func(float f) -> int {
  if(f != 0) { return 654321;}
  else { return 123456; }
}

Is it possible to make MSVC emit a warning on the implicit conversion in the first example?

Viktor Sehr
  • 12,825
  • 5
  • 58
  • 90

1 Answers1

1

No, there is no such warning option in MSVC. You can verify this by compiling your example with /Wall, which enables all warnings, and see that no warning is emitted.

There is, however, one such warning option in Clang: -Wfloat-conversion. The documentation says float to integer, but it includes bool.

szaszm
  • 34
  • 2