$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] safe integer library -- the scope
From: Oliver Kullmann (o.kullmann_at_[hidden])
Date: 2015-12-11 21:47:31
Hello,
On Fri, Dec 11, 2015 at 06:10:01PM -0800, Robert Ramey wrote:
> On 12/11/15 5:50 PM, Robert Ramey wrote:
> To belabor the point, consider this little program:
> 
> #include <iostream>
> #include <cstdint>
> using namespace std;
> int main(){
>     int8_t x = 100;
>     int y = x * x;
>     cout << y << endl;
>     uint32_t z1 = 100;
>     int8_t z2 = -100;
>     auto y2 = z1 * z2;
>     cout << y2 << endl;
> }
> 
> which prints out:
> 
> 10000
> 4294957296
> 
> This is due to the application of the C++ type promotion rules.
> Is it any reason that C++ drives people crazy?
> 
This is the typical behaviour of C++ programmers, which are always
hypercritical about the language, in stark contrast to any other
programming language.
The only problem I see above is that the compiler should issue a
warning for the auto-line. And any reasonable programmer should not
write such code.
Oliver