r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.

Joerg Sonnenberger via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 15 14:57:36 PST 2016


On Fri, Jan 15, 2016 at 02:52:08PM -0800, David Blaikie via cfe-commits wrote:
> On Fri, Jan 15, 2016 at 2:29 PM, Joerg Sonnenberger via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
> 
> > Author: joerg
> > Date: Fri Jan 15 16:29:34 2016
> > New Revision: 257947
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=257947&view=rev
> > Log:
> > Avoid self-assignment of SmallString, trigger UB behavior down the road.
> >
> 
> Shouldn't we be fixing that in SmallString? (self /move/ assignment
> arguably can be UB, but self copy assign probably shouldn't be)

parent_path can effectively onoly return the prefix of the argument, to
the overlap between src and dst is restricted to a prefix as well. I
don't think that's normally the case for a copy assignment from a
reference to the current string. If anything, I'd prefer to have an
assert checking for non-overlap.

Joerg


More information about the cfe-commits mailing list