Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2006-06-27 09:18:22


On Tue, 27 Jun 2006 13:28:39 +0100, Oliver Kullmann
<O.Kullmann_at_[hidden]> wrote:

>In my opinion, a major problem with paying
>attention to warnings and changing the code in order
>to prevent warnings is, that in this way the code
>is not only written for a *special compiler*, but
>even **for a special compiler version**.
>I don't think that this is good practice.

I sympathize will all the points you make. Furthermore many VC level 4
warnings are quite excessive: for instance I get warnings if I do
something like

 static_cast<smaller_int_type>(larger_int_type_expr);

with the intent of truncating a value. Of course the static_cast is
there to prevent a warning but VC8 tells me there's a loss of
information and I should mask the source value. Example:

 unsigned int n = ...
 static_cast<unsigned char>( x & UCHAR_MAX );

It also specifies that there will be no performance loss in optimized
builds, but of course that could not hold for other compilers. And
there's always the risk that another compiler will yield something
like:

 "useless masking used at line xyz" :)

Something could be done with a macro in this case but... is it really
worth? BTW, "C++ Coding Standards" by Sutter/Alexandrescu also
suggests the "wrapping source file" (aka header) approach (on the user
part though, not by boost directly).

--Gennaro.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk