|
Boost : |
Subject: Re: [boost] Current Guidance on Compiler Warnings?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2018-11-28 05:11:35
On Tue, Nov 27, 2018 at 8:57 PM Gavin Lambert via Boost <
boost_at_[hidden]> wrote:
> On 28/11/2018 16:28, Emil Dotchevski wrote:
> > The language currently works correctly in this case, thanks god. The
idea
> > that if x and y are of type short, then x+y should be of type short is
> > utterly wrong. When you add two shorts, you get an int, because
computing
> > the int result does not use more resources than computing the short
result.
>
> That is not always true. There are assembly instructions which can
> operate on values smaller than a register width, and if the compiler
> were able to use them then it might be able to use fewer registers for
> some code patterns.
The optimizer has to use int-size registers only if the int result is
assigned to int. If it's assigned to a short, the optimizer can and does
use short-size registers.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk