This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/39480] generated memcpy causes trouble in assignment



------- Comment #9 from fpbeekhof at gmail dot com  2009-03-17 13:11 -------
Subject: Re:  generated memcpy causes trouble in assignment



paolo dot carlini at oracle dot com wrote:
> ------- Comment #8 from paolo dot carlini at oracle dot com  2009-03-17 12:33 -------
> Yes, if there is a bug, certainly it is not in libstdc++. Also, please find
> somebody able to reproduce it, I can't.

Someone should check whether the part that generates operator=()
generates a memcpy(), in which case there is a bug because that cannot
handle assignment to self, which implies overlapping memory areas, which
in turn, as stated by the standard and confirmed by the existence of
certain pre-fetch instructions, leads to undefined behavior.

This reasoning is valid even if anyone, at any particular time, is able
not to see the symptoms.

If that bug is there, a possible fix would be to replace memcpy by
memmove, as I have suggested.

I don't know in what component gcc generates its operator=(), so if
someone can tell me I'll assign it to that.

Second thing to do is to re-open the bug because it is very real unless
it has been fixed already in a later version.

Third thing is to increase the priority, because this is likely to
affect probably almost all C++ programs, and make all of their behavior
undefined.

I'm not familiar with gcc policies, and maybe someone can check if this
has already been fixed, so I'll wait a few moments before doing these 3
things, to see if there are any reactions.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39480


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]