Pointer semantics in CTFE

Walter Bright newshound2 at digitalmars.com
Tue May 29 14:58:56 PDT 2012


On 5/29/2012 7:20 AM, Michel Fortin wrote:
> Wouldn't it be possible to just catch the case where you compare two pointers
> not assigned from the same memory block and issue an error?
>
> Here's an idea: make each CTFE pointer some kind of struct with a pointer to the
> memory block and an offset. When comparing, if the memory block isn't the same,
> it's an error. If you add or subtract to a pointer, it'll still belong to the
> same memory block but with a different offset, thus it remains comparable. When
> dereferencing, you can make sure the pointer still points inside the block,
> assuming the block knows its length.


That was my suggestion a few posts back in the thread, and Don correctly 
demolished it.



More information about the Digitalmars-d mailing list