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]

Re: type based aliasing again - meaning of "undefined"


On Sep 16, 1999, Marc Espie <espie@quatramaran.ens.fr> wrote:

> In article <19990915154954O.mitchell@codesourcery.com> you write:

>> const int i = 3;
>> int *ip = (int *)&i;
>> *ip = 2;

>> These programs will break when we do the (extremely beneficial
>> to conforming programs) optimization of assuming that `*ip'
>> cannot modify `i'.

> how are you going to deal with the `logical constness' idiom ?

Note that `i' is an actual const, not just a logical const, in this
program.  If you just had a pointer to const int, and you couldn't
tell whether it is just logically constant, you wouldn't be able to
perform this optimization.

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{dcc.unicamp.br,guarana.{org,com}} aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them


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