Subject: Re: [boost] Current Guidance on Compiler Warnings?
From: Daniela Engert (dani_at_[hidden])
Date: 2018-11-24 12:55:44
Am 23.11.2018 um 20:58 schrieb Emil Dotchevski via Boost:
> unsigned f();
> void g( int x )
> if( x < f() ) //warning C4018: '<': signed/unsigned mismatch
The only problem that I can see here is the fact, that this is flagged
as a warning rather than an error. I know, this is technically correct
but you simply cannot compare values from different value domains
without preconditions. Not stating the preconditions is an error. If you
state them and assure that the actual values of both 'x' and 'f()' can
be equally represented as 'int' oder 'unsigned' then and only then the
comparison is correct and a explicit cast to either type is a valid one.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk