ptr1 == ptr2 but (int)ptr1 != (int)ptr2
- From: Hallvard B Furuseth <h.b.furuseth@xxxxxxxxxxx>
- Date: Fri, 25 May 2007 15:28:27 +0200
Do anyone know of an architecture where this can break?
T *ptr1, *ptr2;
...
if (ptr1 == ptr2)
if (CHAR_BIT*sizeof(T*) <= (width of int)) /*otherwise undefined*/
assert((int)ptr1 == (int)ptr2);
(Feel free to replace int with another integer type if that helps to
break something.)
I know an addess can have several representations at least on some DOS
memory models, but I don't know if it normalizes pointers before
converting to integer.
--
Regards,
Hallvard
.
- Follow-Ups:
- Re: ptr1 == ptr2 but (int)ptr1 != (int)ptr2
- From: Malcolm McLean
- Re: ptr1 == ptr2 but (int)ptr1 != (int)ptr2
- From: Kenneth Brody
- Re: ptr1 == ptr2 but (int)ptr1 != (int)ptr2
- Prev by Date: Re: list = list->Next = malloc(sizeof(node));
- Next by Date: Re: IDE for beginner
- Previous by thread: efficient way of looking up huge hashes
- Next by thread: Re: ptr1 == ptr2 but (int)ptr1 != (int)ptr2
- Index(es):
Relevant Pages
|