|
|
Message-ID: <20170706171101.GD1627@brightrain.aerifal.cx>
Date: Thu, 6 Jul 2017 13:11:01 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: Documentation of memcpy and undefined behavior in memset
On Thu, Jul 06, 2017 at 08:02:12PM +0300, Alexander Monakov wrote:
> On Thu, 6 Jul 2017, Rich Felker wrote:
> > FWIW, I think GCC may do aggressive optimization based on the
> > assumption that memcpy implies the pointer points to an object (of
> > size at least 1)
>
> The compiler can deduce that the pointer is non-null (and that's
> fine), but otherwise I don't see what possible optimizations could
> take place. Did you have something specific in mind?
It could presumably move loads from after a branch to before. E.g.
memcpy(q,p,0);
if (whatever) {
y=*p;
...
}
/* y not used after here */
to:
memcpy(q,p,0);
y=*p;
if (whatever) {
...
}
/* y not used after here */
If p points to one past the end of an object that ends on a page
boundary, this transformation could introduce a crash.
Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.