Problem with __gmp_expr
marc.glisse at inria.fr
Fri Jan 17 16:16:47 UTC 2014
On Fri, 17 Jan 2014, Ulrich Drepper wrote:
> On Fri, Jan 17, 2014 at 9:27 AM, Marc Glisse <marc.glisse at inria.fr> wrote:
>> Well, expression template libraries all come with a big WARNING sign... This
>> part of gmpxx has been this way since its creation (before I learnt C++),
>> and people didn't complain that much. std::valarray in gcc's libstdc++
>> should have the same issues.
> valarray uses references only for constant arguments.
Are you sure about that? In bits/valarray_before.h, I see in _BinBase:
const _FirstArg& _M_expr1;
const _SecondArg& _M_expr2;
> non-constant arguments it creates expression objects which in some
> situations have to be explicitly casted or assigned. This is the type
> of safety the gmpxx code could use as well.
I'd like to be shown precisely where valarray is doing something
> It is somewhat against the principals of gmp which allows the
> knowledgeable user to write optimized code.
Not sure how this is preventing anyone from writing optimized code in the
example you provided. You don't need to use auto, lambda, or even an
intermediate variable. Maybe you have a different example in mind?
More information about the gmp-bugs