Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Address of array && address of pointer to array

Reply
Thread Tools

Address of array && address of pointer to array

 
 
Keith Thompson
Guest
Posts: n/a
 
      09-16-2011
Stanley Rice <(E-Mail Removed)> writes:
> On Sep 16, 9:18*am, James Kuyper <(E-Mail Removed)> wrote:
>> On 09/15/2011 09:13 PM, Stanley Rice wrote:
>> > On Sep 16, 2:51 am, Keith Thompson <(E-Mail Removed)> wrote:

>> ...
>> >> It's likely to work in practice (and I think POSIX requires it
>> >> to work), but there have been systems where function pointers are
>> >> bigger than void*, so the conversion could lose information.

>>
>> > I am not fully understand your meaning of "function pointers are
>> > bigger than void *". I know it's not the size of the pointer.

>>
>> You "know" incorrectly. Function pointers can have a size that is
>> different from the size of void*, and there have been many systems where
>> this is indeed the case.
>> --
>> James Kuyper

>
> But I try to print sizeof(void *) and sizeof(ptr2fun), supposing that
> ptr2fun is a function pointer. It generate the same result, both are
> 4. So is your meaning that in some special cases, the size of function
> pointer and the pointer to void * is different? And could you explain
> to me when it occurs?


You've demonstrated that void* and ptr2fun have the same size *under
your implementation*. That says nothing about other implementations,
or about what the language standard requires.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
 
Kenny McCormack
Guest
Posts: n/a
 
      09-16-2011
In article <(E-Mail Removed)>,
Keith Thompson <(E-Mail Removed)> wrote:
>Nobody <(E-Mail Removed)> writes:
>[...]
>> However: I suggest that it would be legal for the implementation to print
>> all pointers as "?" if it can detect that the *scanf() functions aren't
>> used by the program.

>
>Legal, yes. Sane, no.


That doesn't matter around here, does it?

--
One of the best lines I've heard lately:

Obama could cure cancer tomorrow, and the Republicans would be
complaining that he had ruined the pharmaceutical business.

(Heard on Stephanie Miller = but the sad thing is that there is an awful lot
of direct truth in it. We've constructed an economy in which eliminating
cancer would be a horrible disaster. There are many other such examples.)
 
Reply With Quote
 
 
 
 
Peter Nilsson
Guest
Posts: n/a
 
      09-19-2011
Keith Thompson <(E-Mail Removed)> wrote:
> Nobody <(E-Mail Removed)> writes:
> > However: I suggest that it would be legal for the
> > implementation to print all pointers as "?" if it can
> > detect that the *scanf() functions aren't used by the
> > program.

>
> Legal, yes. ...


I disagree. Implementation-defined does not mean anything goes.
I don't think '?' for all pointers can be said to be the 'value
of the pointer converted to a sequence of printing characters.'

Would you say puts() is free to only ever output '?' since no
strictly conforming program can read it back from stdout?

--
Peter
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      09-20-2011
Peter Nilsson <(E-Mail Removed)> writes:
> Keith Thompson <(E-Mail Removed)> wrote:
>> Nobody <(E-Mail Removed)> writes:
>> > However: I suggest that it would be legal for the
>> > implementation to print all pointers as "?" if it can
>> > detect that the *scanf() functions aren't used by the
>> > program.

>>
>> Legal, yes. ...

>
> I disagree. Implementation-defined does not mean anything goes.
> I don't think '?' for all pointers can be said to be the 'value
> of the pointer converted to a sequence of printing characters.'
>
> Would you say puts() is free to only ever output '?' since no
> strictly conforming program can read it back from stdout?


I concede; always printing "?" would not be conforming, since it
does not meaningfully satisfy the requirement (vague though that
requirement is).

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
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
pointer to an array vs pointer to pointer subramanian100in@yahoo.com, India C Programming 5 09-23-2011 10:28 AM
Pointer to array of array of const pointer RSL C++ 14 02-19-2010 02:06 PM
Array of pointer and pointer of array erfan C Programming 6 01-28-2008 08:55 PM
passing the address of a pointer to a func that doesnt recieve a pointer-to-a-pointer jimjim C Programming 16 03-27-2006 11:03 PM
Array of pointer Vs Pointer to Array sangeetha C Programming 9 10-09-2004 07:01 PM



Advertisments