Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: pointer to ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 13 of 13 Topic 26068 of 27670
Post > Topic >>

Re: pointer to integer to pointer conversions

by Peter Nilsson <airia@[EMAIL PROTECTED] > May 7, 2008 at 03:44 PM

vipps...@[EMAIL PROTECTED]
 wrote:
> vippstar wrote:
> > That's possible. Using `intptr_t' or `uintptr_t'.
> > You have to include <stdint.h> to use it.
> > There is also uintptr_t, which you will use to store the void pointer
> > does not matter.
> > The type only matters if you use it in arithmetic.
> > ie, uintptr_t foo = malloc(123); foo = ~foo; free((void*)~free);
>                      ^                                      ^^^^
> > With intptr_t undefined behavior might be invoked in this
> > example (if, for example, malloc() returns NULL)
>
> Ignore the small error I made (typing free instead of foo), and
> that I did not cast malloc(123) to (uintptr_t), which might be
> necessary.

It is.

> The point of this snip is to show that ~ in signed integer with
> value 0 might be a trap representation, which you can avoid
> by using an unsigned integer. I cannot think of an example
> that signed is preferred to unsigned, but there has to be at
> least one.

There are ha****ng techniques that involve negative values.
[Note that Java has no unsigned types.]

--
Peter
 




 13 Posts in Topic:
pointer to integer to pointer conversions
lithiumcat@[EMAIL PROTECT  2008-05-06 05:05:39 
Re: pointer to integer to pointer conversions
vippstar@[EMAIL PROTECTED  2008-05-06 05:34:20 
Re: pointer to integer to pointer conversions
Eric Sosman <esosman@[  2008-05-06 08:37:09 
Re: pointer to integer to pointer conversions
rlb@[EMAIL PROTECTED] (R  2008-05-07 08:17:12 
Re: pointer to integer to pointer conversions
"Stephen Sprunk"  2008-05-07 16:37:01 
Re: pointer to integer to pointer conversions
Keith Thompson <kst-u@  2008-05-07 15:45:19 
Re: pointer to integer to pointer conversions
lithiumcat@[EMAIL PROTECT  2008-05-06 08:33:00 
Re: pointer to integer to pointer conversions
Keith Thompson <kst-u@  2008-05-06 12:46:11 
Re: pointer to integer to pointer conversions
Flash Gordon <spam@[EM  2008-05-06 21:42:38 
Re: pointer to integer to pointer conversions
vippstar@[EMAIL PROTECTED  2008-05-07 06:54:46 
Re: pointer to integer to pointer conversions
Peter Nilsson <airia@[  2008-05-07 15:30:26 
Re: pointer to integer to pointer conversions
rlb@[EMAIL PROTECTED] (R  2008-05-08 12:52:49 
Re: pointer to integer to pointer conversions
Peter Nilsson <airia@[  2008-05-07 15:44:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 21:58:08 CDT 2008.