[Issue 10763] (&x)[0 .. 1] doesn't work in CTFE

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 19 03:25:14 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10763



--- Comment #6 from timon.gehr at gmx.ch 2013-08-19 03:25:14 PDT ---
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > ...
> > > The corner cases arise if you still disallow &x + 1. My guess is that you're
> > > allowing it in your implementation?
> > > ...
> > 
> > Yes, but dereferencing it is an error. Subtracting one results in the address
> > of x.
> 
> That is not the issue. The problem is that in C, simply creating the pointer is
> undefined behaviour. 

I guess I'll update my implementation eventually to disallow this. (Other
related limitations are that it currently allows escaping addresses to locals
and simply closes over them, array appends may cause non-determinism and
pointers can be freely compared.)

> ...
> > > Is there really a use case for this unsafe behaviour?
> > 
> > Make more code CTFE-able.
> 
> But it's undefined behaviour.

There is not really a reason why (&x)[0..1] should be UB. But I guess if you
want to keep C behaviour and also keep the invariant that slices always point
to arrays, this is indeed not fixable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list