aliasing between const and non-const objects
Gabriel Dos Reis
gdr@integrable-solutions.net
Tue Jul 29 18:20:00 GMT 2003
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
More information about the Gcc
mailing list