ldmud/test/t-language/tl-warnfloatbool1.c
Alexander Motzkau e3e353661b Warn about floats being used in a boolean context
Floats historically are always interpreted as true (only the integer zero
will be considered false), so even if 0.0 compares equal to (int)0 it is
not seen as false. This may be counter-intuitive. Therefore warn about
float values used as a condition when pragma warn_deprecated is in effect.
(Resolves #780)
2022-01-08 22:16:53 +01:00

13 lines
162 B
C

#pragma warn_deprecated
int fun(float var)
{
if (var)
return 1;
return -1;
}
int run_test()
{
return __MASTER_OBJECT__.warning_occured();
}