Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Why (type*)pointer isn't equal to *(type**)pointer?

Reply
Thread Tools

Why (type*)pointer isn't equal to *(type**)pointer?

 
 
Peter Shaggy Haywood
Guest
Posts: n/a
 
      01-17-2006
Groovy hepcat Richard Heathfield was jivin' on Sat, 14 Jan 2006
09:17:41 +0000 (UTC) in comp.lang.c.
Re: Why (type*)pointer isn't equal to *(type**)pointer?'s a cool
scene! Dig it!

>lovecreatesbeauty said:
>In this case, the pointer &ch is converted to int *, but there is no
>guarantee that a char is aligned in a manner proper to int. So the pointer
>is (at least potentially) invalid, and the code is therefore not portable.
>
>> 10 p2 = *(int **)(&ch);

>
>The same applies, so again this is not portable C.


Yes, and this is even worse still. The OP is actually dereferencing
the pointer here. And you know what happens when one dereferences a
pointer pointing at an object of an incompatible type. BANG! Undefined
behaviour!

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
 
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
Internet Sharing: Equal upload speeds but un-equal download speeds =?Utf-8?B?TkpU?= Wireless Networking 3 09-15-2007 06:22 AM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
int a[10]; int* p=(int*)((&a)+1); But why p isn't equal to ((&a)+1)? aling C++ 8 10-20-2005 02:42 PM
My Agent downloads two equal files, why? Jones Computer Information 2 11-01-2003 12:39 AM



Advertisments