digitalmars.D.bugs - DMD message of the day ...
- kris (3/3) Mar 29 2006 "incompatible types for ((cast(void*)(src)) + (cast(void*)*(p))):
- Tom S (4/8) Mar 30 2006 Not really a bug, though the error message might be 'cannot add two
- Unknown W. Brackets (5/9) Mar 30 2006 Shouldn't you make them ubytes or something first?
- kris (20/33) Mar 30 2006 Yeah ... it is a bit odd :)
- Unknown W. Brackets (4/45) Mar 31 2006 Why are you using a pointer type for ptr? That's just asking for
"incompatible types for ((cast(void*)(src)) + (cast(void*)*(p))): 'void*' and 'void*'" :)
Mar 29 2006
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
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
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]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"incompatible types for ((cast(void*)(src)) + (cast(void*)*(p))): 'void*' and 'void*'" :)
Mar 30 2006
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]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"incompatible types for ((cast(void*)(src)) + (cast(void*)*(p))): 'void*' and 'void*'" :)
Mar 31 2006