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: auto const ints and pointer issue


On Tue, Jun 17, 2008 at 9:44 PM, Karen Shaeffer
<shaeffer@neuralscape.com> wrote:
> On Tue, Jun 17, 2008 at 11:01:31AM -0700, Ian Lance Taylor wrote:
>> > ~~~~~~~~~~~~~~~~ output ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> > $ const_ints
>> > const int ic = 0   *cip = 5   *ip = 5
>> > &ic = 0xbfbd72a0    cip = 0xbfbd72a0    ip = 0xbfbd72a0
>> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>
In my opinion, it seems reasonable to limit the undefined
> behavior to the value of the variable, or to some form of
> failure and error, up to and including crashing the process.
> But to implement the code in such a way to let the process
> proceed without error, and to have incorrect addresses as we
> see here, seems to be beyond the common sense scope of the bounds
> of what this assignment's undefined behavior potential effects
> might be. It is interesting. Thank you for your comment.

I don't see the issue with the pointers being the same.  I don't see
what you are asking to be different.  Casting from one pointer type to
another is ok.  So we can go from:
 cip = &ic;
 ip = (int *)cip;
 cip = ip;

And cip should be the same as &ic at the end of that code sequence.

Thanks,
Andrew Pinski


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