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: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Michael Matz <matz at suse dot de>
- Cc: Richard dot Earnshaw at arm dot com, gcc at gcc dot gnu dot org
- Date: 29 Jul 2003 20:08:10 +0200
- Subject: Re: aliasing between const and non-const objects
- Organization: Integrable Solutions
- References: <Pine.LNX.4.44.0307291941380.17944-100000@wotan.suse.de>
Michael Matz <matz@suse.de> writes:
| Hi,
|
| On Tue, 29 Jul 2003, Richard Earnshaw wrote:
|
| > > 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.
|
| That the other way around. There you add the const qualifier, but
| removing it (implicitely or explicitely) gives a warning:
you're confused (by snipping context).
Here is the example Richard gave
(see http://gcc.gnu.org/ml/gcc/2003-07/msg02008.html)
foo()
{
int a[5];
t = a; c = a;
f();
}
For "c", we have a const-qualification conversion "int* -> const int*",
which is just fine.
You then replied:
> foo()
> {
> int a[5];
>
> t = a; c = a;
You'll get a warning for the latter assignment, though.
which is plain wrong. If the compiler does what you said then it is broken.
-- Gaby