This is the mail archive of the gcc@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]

Re: PR c++/39480 not really fixed


On Fri, Oct 28, 2011 at 12:21 PM, David Miller <davem@davemloft.net> wrote:
> From: Richard Guenther <richard.guenther@gmail.com>
> Date: Fri, 28 Oct 2011 11:27:25 +0200
>
>> On Fri, Oct 28, 2011 at 9:48 AM, David Miller <davem@davemloft.net> wrote:
>>>
>>> g++.dg/init/copy7.C makes sure that memcpy() is not emitted with
>>> src and dst equal.
>>
>> The testcase is bogus and should be removed. ?See the patch I posted
>> (and the PR). ?Unfortunately the patch didn't get any review yet.
>
> Thanks. ?Which patch and PR are you talking about, 39480?

PR50079, the patch simply deletes the testcase.

> Meanwhile, if the conclusion is that memcpy(x, x, ...) is legal, I
> disagree. ?I can think of implementations where this will break.

Then we have to fix the middle-end which will happily expand
block-moves to memcpy with exact overlap (a = a is valid in C).
See the PR and the C testcases therein.

Just trying to avoid this in the C++ frontend is bogus.

> For example, if the memcpy implementation does a cache initializing
> store on the first cache line of the destination before fetching the
> beginning of the source, such memcpy() calls with src==dst will
> produce garbage.

Of course, as Linus would say, such implementation would be "broken" ;)
(I expect that such implementations can (and would) easily avoid the situation
with almost no cost by doing an early out for src == dst).

Richard.


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