Re: Simple question on Pointers
- From: "Alan Carre" <alan@xxxxxxxxxxxxxxxxx>
- Date: Sun, 30 Nov 2008 02:09:20 +0700
"Doug Harrison [MVP]" <dsh@xxxxxxxx> wrote in message
news:cjkoi4997sn001434flljij4o7vg423avj@xxxxxxxxxx
On Tue, 25 Nov 2008 06:44:03 +0700, "Alan Carre" <alan@xxxxxxxxxxxxxxxxx>
The real problem is that dereferencing &a+1 is undefined. If we assume
that
the storage for "a" is at location 0, &a will produce a pointer that
points
to location 0, but it has the type char(*)[12]. Therefore, when you say
&a+1, you are referring to memory location 12, and when you dereference
this expression, you're reading past the end of the array "a" into
uninitialized memory. Perhaps this is what the warning is trying to say,
but it's very misleading for it to describe "a" as "uninitialized",
because
it certainly is initialized.
I will refer you to my response to "Cezary H. Noweta" above in this thread
which demonstrates that the above "explanation" is incorrect.
Again, the array "a" is certainly initialized, and a[i] are not separate
variables; they are all part of "a". BTW, I thought we were talking about
a
char[12]. :)
I don't know what a "char[12]" is. Perhaps you're thinking we're talking
about FORTRAN or something. There is no such thing as a char[12] as far as
the C++ language is concerned.
- Alan Carre
.
- Follow-Ups:
- Re: Simple question on Pointers
- From: Doug Harrison [MVP]
- Re: Simple question on Pointers
- From: Alexander Grigoriev
- Re: Simple question on Pointers
- From: Doug Harrison [MVP]
- Re: Simple question on Pointers
- From: Tommy
- Re: Simple question on Pointers
- References:
- Simple question on Pointers
- From: Robby
- Re: Simple question on Pointers
- From: Alan Carre
- Re: Simple question on Pointers
- From: Doug Harrison [MVP]
- Simple question on Pointers
- Prev by Date: Re: Simple question on Pointers
- Next by Date: Re: Simple question on Pointers
- Previous by thread: Re: Simple question on Pointers
- Next by thread: Re: Simple question on Pointers
- Index(es):