Boost logo

Boost :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2002-05-10 09:38:40


Philippe Lalande wrote:
>
> I am not sure if it is really a compiler bug. gcc 2.95.2 results to your
> program is un-intuitive either as b's value is 2147483647 (same as
> MSVC6SP5).
>

[snip]

As Dave pointed out, it is probably not a compiler bug. After digging
through the standard, I came up with the following.

5.6.2 states, that "the usual arrithmetic conversions are performed
on the operands and determine the type of the result".

What the "usual arrithmetic conversions" are I can't say. My guess
is that it's not an integral promotion (4.5) but an integral
conversion (4.7).

When looking this up in my old Stroustrup it tells me that according
to r.4.5 (arithmetic conversions), "if either operand is unsigned
the other is converted to unsigned".

Makes you wonder if the rules are broken, as they seem to require
this behaviour... :-(

In my opinion, any compiler which doesn't flag such a dangerous
conversion with a warning is buggy.

Markus


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