[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gettext] [Patch 1/2] Libasprintf bug fixes

From: Miguel Ángel
Subject: Re: [bug-gettext] [Patch 1/2] Libasprintf bug fixes
Date: Mon, 04 Mar 2013 13:01:23 +0100

Daiki Ueno <address@hidden>: 
> I'm not familiar with C++, but is 'tmp' really needed here?
>     autosprintf& operator = (autosprintf& src)

First of all, const correctness.
This would be fine with a move reference (C+11) autosprintf&& src, but a
copy constructor must not modify the copied object.

>     {
>       std::swap (str, src.str);

Think what happens when this is called from this line (a and b are
autosprintf objects):
a = b;
This call would swap the strings a.str and b.str, but it is not the
desired behavior, you want to free a.str and copy b.str into a.str.

The this pointer check is not needed with this copy pattern (copy
constructor and swap), but it optimizes out the useless copy at:
a = a;

Best regards,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]