[Issue 10266] CTFE: Allow reinterpret casts T <-> T[1]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 18 00:31:48 PDT 2013


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



--- Comment #1 from Don <clugdbug at yahoo.com.au> 2013-06-18 00:31:47 PDT ---
Supporting this would create a *huge* number of corner cases.

For example, CTFE strictly enforces C pointer arithmetic.

int b;
int * p = &b;
++p;  // illegal, can only do pointer arithmetic on pointers to arrays

int[1] n;
int *q = &n[0];
++q; // ok, one past the end of an array is explicitly legal

I'm not sure if that cast leads to well-defined behaviour in C. I suspect that
after the cast, it might not be a genuine array.
I think a 16bit C compiler could legally put b at location 0xFFFC, then after
++p, p would be 0. Which could never happen with a proper array.

Of course all this stuff could be implemented, but sticking to C rules makes
things very much easier, because it eliminates so many of these nasty cases.

-- 
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