This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: aliasing between const and non-const objects


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]