www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - DMD message of the day ...

reply kris <foo bar.com> writes:
"incompatible types for ((cast(void*)(src)) + (cast(void*)*(p))): 
'void*' and 'void*'"

:)
Mar 29 2006
next sibling parent Tom S <h3r3tic remove.mat.uni.torun.pl> writes:
kris wrote:
 "incompatible types for ((cast(void*)(src)) + (cast(void*)*(p))): 
 'void*' and 'void*'"
 
 :)
Not really a bug, though the error message might be 'cannot add two pointers' or something alike :) Tomasz Stachowiak /+ a.k.a. h3r3tic +/
Mar 30 2006
prev sibling parent reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
Shouldn't you make them ubytes or something first?

Also, forgive my ignorance, but for what good reason would you add two 
pointers?  Subtracting is great and wonderful... adding a pointer and an 
int is amazing...  but adding pointers?

-[Unknown]


 "incompatible types for ((cast(void*)(src)) + (cast(void*)*(p))): 
 'void*' and 'void*'"
 
 :)
Mar 30 2006
parent reply kris <foo bar.com> writes:
Unknown W. Brackets wrote:
 Shouldn't you make them ubytes or something first?
 
 Also, forgive my ignorance, but for what good reason would you add two 
 pointers?  Subtracting is great and wonderful... adding a pointer and an 
 int is amazing...  but adding pointers?
 
 -[Unknown]
 
 
 "incompatible types for ((cast(void*)(src)) + (cast(void*)*(p))): 
 'void*' and 'void*'"

 :)
Yeah ... it is a bit odd :) This came up when serializing & deserializing arrays. I ended up modifying each array pointer|length pair to be an offset|length pair instead, and then writing that pair as though it were an ordinary field (like a long int). When deserializing, the offset|length pair gets converted back to a pointer|length pair by adding a base-address to the offset. Hence, we end up with what /looks/ like the addition of two pointers. The decoding looked something like this: void* base_address; void[]* p = address_of_encoded_array; *p = (base_address + (*p).ptr)[0 .. (*p).length]; where (*p).ptr is actually the encoded offset, rather than a pointer. That's where DMD tossed the amusing "void* is incompatible with void*" error. This was fixed by removing the .ptr syntax, causing DMD to extract the offset via implicit type-casting instead (matching the void* on the LHS). The approach is a bit grubby, but that's ok. - Kris
Mar 30 2006
parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
Why are you using a pointer type for ptr?  That's just asking for 
trouble, imho... why not use a ptrdiff_t (which is designed for this 
very purpose, afaik)?  Or do you hate those types for some reason?

-[Unknown]


 Unknown W. Brackets wrote:
 Shouldn't you make them ubytes or something first?

 Also, forgive my ignorance, but for what good reason would you add two 
 pointers?  Subtracting is great and wonderful... adding a pointer and 
 an int is amazing...  but adding pointers?

 -[Unknown]


 "incompatible types for ((cast(void*)(src)) + (cast(void*)*(p))): 
 'void*' and 'void*'"

 :)
Yeah ... it is a bit odd :) This came up when serializing & deserializing arrays. I ended up modifying each array pointer|length pair to be an offset|length pair instead, and then writing that pair as though it were an ordinary field (like a long int). When deserializing, the offset|length pair gets converted back to a pointer|length pair by adding a base-address to the offset. Hence, we end up with what /looks/ like the addition of two pointers. The decoding looked something like this: void* base_address; void[]* p = address_of_encoded_array; *p = (base_address + (*p).ptr)[0 .. (*p).length]; where (*p).ptr is actually the encoded offset, rather than a pointer. That's where DMD tossed the amusing "void* is incompatible with void*" error. This was fixed by removing the .ptr syntax, causing DMD to extract the offset via implicit type-casting instead (matching the void* on the LHS). The approach is a bit grubby, but that's ok. - Kris
Mar 31 2006