[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,
Miguel
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, (continued)
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, Miguel Ángel, 2013/03/04
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, Daiki Ueno, 2013/03/04
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, Miguel Ángel Arruga Vivas, 2013/03/05
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, Daiki Ueno, 2013/03/05
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, Miguel Ángel Arruga Vivas, 2013/03/06
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, Didier Spaier, 2013/03/06
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, Miguel Ángel Arruga Vivas, 2013/03/06
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, Daiki Ueno, 2013/03/06
- Re: [bug-gettext] [Patch 2/2] Libasprintf bug fixes, Miguel Ángel Arruga Vivas, 2013/03/07
Re: [bug-gettext] [Patch 1/2] Libasprintf bug fixes, Daiki Ueno, 2013/03/04
- Re: [bug-gettext] [Patch 1/2] Libasprintf bug fixes,
Miguel Ángel <=