This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: aliasing between const and non-const objects
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Michael Matz <matz at suse dot de>
- Cc: Richard dot Earnshaw at arm dot com, gcc at gcc dot gnu dot org
- Date: Tue, 29 Jul 2003 17:20:48 +0100
- Subject: Re: aliasing between const and non-const objects
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> Hi,
>
> On Tue, 29 Jul 2003, Richard Earnshaw wrote:
>
> > Incorrect. External code could quite legitimately be:
>
> Hmm, right. I'm obviously blind and barking up the wrong tree :-|
>
> > foo()
> > {
> > int a[5];
> >
> > t = a; c = a;
>
> You'll get a warning for the latter assignment, though. Nevethess you are
> right. I should have provided a more complete example:
I hope not. Otherwise you would get a warning every time you passed a
non-const char pointer to strcpy as a source argument.
The code is not much dissimilar to
char a[5] = "abc";
char b[5];
strcpy (b, a);
R.