This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/50417] regression: memcpy with known alignment
- From: "gjl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 09 Jul 2016 12:57:57 +0000
- Subject: [Bug tree-optimization/50417] regression: memcpy with known alignment
- Auto-submitted: auto-generated
- References: <bug-50417-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50417
--- Comment #18 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
(In reply to rguenther@suse.de from comment #12)
> On Fri, 8 Jul 2016, olegendo at gcc dot gnu.org wrote:
>
> > void test (const int *a, int *b)
> > {
> > a[100] = 1;
> > b[200] = 2;
> >
> > std::memcpy ((char *)b, (char *)a, t);
> > }
> >
> > where a[100] and b[200] both would result in 32 bit accesses, not 4x1 byte or
> > something, because the base pointer is assumed to be int aligned.
>
> No, because the access is performed as 'int'.
>
> > Why should memcpy be any different?
>
> Because the memcpy stmt doesn't constitute a memory access but a function
> call.
What about a new command option like -fassume-aligned-xxx that's off per
default?
The user could assert that when she is using memcpy (and friends) with a
pointer of a specific type, then that also asserts that the data behind the
pointer is appropriately aligned and may be accessed accordingly.