Always false float comparisons

Xinok via Digitalmars-d digitalmars-d at puremagic.com
Mon May 9 20:00:14 PDT 2016


On Monday, 9 May 2016 at 20:14:36 UTC, Walter Bright wrote:
> On 5/9/2016 11:37 AM, Xinok wrote:
>> All of these scenarios are capable of producing "incorrect" 
>> results, are a
>> source of discrete bugs (often corner cases that we failed to 
>> consider and
>> test), and can be hard to detect. It's about time we stopped 
>> being stubborn and
>> flagged these things as warnings. Even if they require a 
>> special compiler flag
>> and are disabled by default, that's better than nothing.
>
> I've used a B+D language that does as you suggest (Wirth 
> Pascal). It was highly unpleasant to use, as the code became 
> littered with casts. Casts introduce their own set of bugs.

Maybe it's a bad idea to enable these warnings by default but 
what's wrong with providing a compiler flag to perform these 
checks anyways? For example, GCC has a compiler flag to yield 
warnings for signed+unsigned comparisons but it's not even 
enabled with the -Wall flag, only by specifying -Wextra or 
-Wsign-compare.


More information about the Digitalmars-d mailing list