This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC][13/19] Target FP: Perform Ada fixed-point scaling in target format
On Mon, 9 Oct 2017, Simon Marchi wrote:
> > Let's wait for people who really know better about C++ to tell us
> > whether it makes a difference. I was amazed as how careful you have
> > to be when using C++ to avoid inefficiencies, but perhaps I am simply
> > being paranoid in this case... That's why I tried to phrase this as
> > a question.
> >
>
> Indeed, it's preferable to use
>
> std::string foo = returns_string ();
>
> than
>
> std::string foo;
> foo = returns_string ();
>
> The reason being that in the second case, the default constructor (the
> one with no params) is called to construct an empty string, and then that
> work is scrapped because we assign a new value. The first form constructs
> the string right away with the right content.
Hmm, wouldn't a half-decent compiler notice that the result produced by
the default constructor is discarded and optimise the call away? Also has
there actually been an assertion in (the current definition of C++) that
all declared objects have also been initialised?
Maciej the curious