Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Where do pointers point to?

Reply
Thread Tools

Where do pointers point to?

 
 
S.Tobias
Guest
Posts: n/a
 
      01-13-2005
Lawrence Kirby <(E-Mail Removed)> wrote:
> On Thu, 13 Jan 2005 10:30:49 +0000, S.Tobias wrote:


> > Jack Klein <(E-Mail Removed)> wrote:
> >
> >> void* is a pointer to object type, even though it happens to point to
> >> an incomplete type that can't be completed.

> >
> > Nit-pick: While I perfectly understand the intention, it doesn't make
> > sense reading strictly. Object and incomplete types are disjoint groups
> > (ie. object types are not divided into complete and incomplete types
> > - I fell into this trap recently), although both describe objects (6.2.5#1).
> > IMHO it'd be better to say: "void* is an object pointer".


> Don't confuse the type of a pointer and what it points to. Usually there
> is a direct relation but not with pointers to incomplete types. It is
> perfectly reasonable for a pointer to an incomplete type to point at an
> object,

[snip]

I fully agree. Jacks Klein's words could be understood as: "a (pointer
to object) type", but then I think the parentheses would be necessary.
I'm not going to argue on the precedence of word linkage in English
language, but my common/colloquial/vulgar/illiterate*) understanding
was "a pointer to (object type)". /Object type/ can never be
/incomplete type/ and v.v., and neither can be type pointer to thereof.
I made my remark for those who might be confused like I was before.

*) choose most appropriate

I hope I'm sufficiently clear.

--
Stan Tobias
mailx `echo http://www.velocityreviews.com/forums/(E-Mail Removed)LID | sed s/[[:upper:]]//g`
 
Reply With Quote
 
 
 
 
Mark Piffer
Guest
Posts: n/a
 
      01-14-2005
Christian Bau <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...

>In article <cs21on$27hl$(E-Mail Removed)>,
> "x-pander" <(E-Mail Removed)> wrote:
>
>> > You need to make it run on littleendian hardware.
>> > You have the source code to the compiler. Instead of changing 10

million
>> > lines of code, change the compiler so that the "first" byte is at

a
>> > higher address than the last byte; where "p++;" would usually be
>> > translated into a hardware instruction that adds sizeof (*p), it

will be
>> > translated to a hardware instruction that subtracts sizeof (*p).

Pointer
>> > comparisons say that p < q if a hardware compare instruction says

p > q
>> > and so on. Now a pointer always points to the highest addressed

byte,
>> > and it is completely conforming and invisible to the programmer.

>>
>> An example situation in described system could be:
>>
>> int x;
>> &x == 0x4003
>> (void *)&x == 0x4003
>> (char *)&x == 0x4000
>> (void *)(char *)&x = 0x4000

>
>No; (char *)&x would be == 0x4003. The first byte would be at address
>0x4003, the second byte at address 0x4002, and so on. ((char *) &x) +

1
>would be == 0x4002. If you compare ((char *) &x) < ((char *) &x) + 1,
>the result is true (1).


I apologize for my other, pointless, posting. Only after submitting I
noted the subtle requirement you stated, that is, making a
*non-portable* app running on a reverse endianess architecture. Of
course your reasonings are correct (as always .

Mark
 
Reply With Quote
 
 
 
 
Lawrence Kirby
Guest
Posts: n/a
 
      01-14-2005
On Thu, 13 Jan 2005 19:43:30 +0000, S.Tobias wrote:

> Lawrence Kirby <(E-Mail Removed)> wrote:
>> On Thu, 13 Jan 2005 10:30:49 +0000, S.Tobias wrote:

>
>> > Jack Klein <(E-Mail Removed)> wrote:
>> >
>> >> void* is a pointer to object type, even though it happens to point to
>> >> an incomplete type that can't be completed.
>> >
>> > Nit-pick: While I perfectly understand the intention, it doesn't make
>> > sense reading strictly. Object and incomplete types are disjoint groups
>> > (ie. object types are not divided into complete and incomplete types
>> > - I fell into this trap recently), although both describe objects (6.2.5#1).
>> > IMHO it'd be better to say: "void* is an object pointer".

>
>> Don't confuse the type of a pointer and what it points to. Usually there
>> is a direct relation but not with pointers to incomplete types. It is
>> perfectly reasonable for a pointer to an incomplete type to point at an
>> object,

> [snip]
>
> I fully agree. Jacks Klein's words could be understood as: "a (pointer
> to object) type",


However I'm uneasy about your statement "void* is an object pointer" for
similar reasons. It mixes too many concepts to provide a clear statement
of what is happening. In terms of type void* isn't an object pointer.
However at runtime a void* pointer is capable of pointing at objects in a
loose sense.

Lawrence
 
Reply With Quote
 
S.Tobias
Guest
Posts: n/a
 
      01-15-2005
Lawrence Kirby <(E-Mail Removed)> wrote:
> On Thu, 13 Jan 2005 19:43:30 +0000, S.Tobias wrote:


> > Lawrence Kirby <(E-Mail Removed)> wrote:
> >> On Thu, 13 Jan 2005 10:30:49 +0000, S.Tobias wrote:

> >
> >> > Jack Klein <(E-Mail Removed)> wrote:
> >> >
> >> >> void* is a pointer to object type, even though it happens to point to
> >> >> an incomplete type that can't be completed.
> >> >
> >> > Nit-pick: While I perfectly understand the intention, it doesn't make
> >> > sense reading strictly. Object and incomplete types are disjoint groups
> >> > (ie. object types are not divided into complete and incomplete types
> >> > - I fell into this trap recently), although both describe objects (6.2.5#1).
> >> > IMHO it'd be better to say: "void* is an object pointer".

> >
> >> Don't confuse the type of a pointer and what it points to. Usually there
> >> is a direct relation but not with pointers to incomplete types. It is
> >> perfectly reasonable for a pointer to an incomplete type to point at an
> >> object,

> > [snip]
> >
> > I fully agree. Jacks Klein's words could be understood as: "a (pointer
> > to object) type",


> However I'm uneasy about your statement "void* is an object pointer" for
> similar reasons. It mixes too many concepts to provide a clear statement
> of what is happening.


Now what did I say wrong? The Standard itself uses words (but not terms)
"function pointers" and "object pointers". Grep through n869.txt.
What's this hair-splitting about?

> In terms of type void* isn't an object pointer.


Why? The Standard demands that void* be able to point to objects, and
nothing else.

Besides, see 7.18.1.4 and look what "object pointers" in the title
refers to.

> However at runtime a void* pointer is capable of pointing at objects in a
> loose sense.


My understanding has been an "object" to be a range of memory where
values can be stored. What "looser" sense can there be? Perhaps
void* can point to other things too, like functions, but these
are extensions.

--
Stan Tobias
mailx `echo (E-Mail Removed)LID | sed s/[[:upper:]]//g`
 
Reply With Quote
 
pete
Guest
Posts: n/a
 
      01-15-2005
S.Tobias wrote:

> Now what did I say wrong?
> The Standard itself uses words (but not terms)
> "function pointers" and "object pointers". Grep through n869.txt.
> What's this hair-splitting about?


My C89 last public draft also has the substrings of
"object pointer" and "function pointer"

I like the term "object pointers" to refer to pointers to
object types and pointers to incomplete types collectively,
and I like "function pointers" to mean pointers to function types.

--
pete
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
pointers, pointers, pointers... cerr C Programming 12 04-07-2011 11:17 PM
Scenario 5: IS-IS routing on Frame Relay Multi-point and Point-to-Point David Sudjiman Cisco 0 06-08-2006 09:11 AM
pointers to pointers // exception handling error muser C++ 3 09-18-2003 06:19 PM
Template specialization of pointers with function pointers Phil C++ 1 09-16-2003 02:17 AM



Advertisments