[Issue 9957] [2.061 -> 2.062] Taking pointer of enum float array gives some garbage

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 24 04:06:02 PDT 2013


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



--- Comment #8 from Don <clugdbug at yahoo.com.au> 2013-04-24 04:05:58 PDT ---
(In reply to comment #7)
> (In reply to comment #6)
> > I agree with Don. Enums do not have an address (even if under the hood they
> > do). Users should use 'const' or 'immutable' if they need it to have an
> > address.
> 
> OK. It's not bad design. But implementing it is not so easy. Because
> 
> 1. Current dmd does not have such information internally. CTFE engine now uses
> ownedByCtfe flag, but using it in semantic analysis is not intended.
> 
> 2. It is not well designed enough. For example:
> 
>     enum float[] A = [1.0, 2.0, 3.0];
>     auto a = A.ptr;  //?
> 
> In this case, the elements of A would be allocated on the runtime heap, or "not
> addressable compile time memory"? Currently it operates as the former, but it
> should be prohibited?

I think it should be prohibited. In fact, the problem starts here:

>     enum float[] A = [1.0, 2.0, 3.0];

I think, a bit controversially, that this line shouldn't compile. 
See bug 9953.
An enum of a reference type doesn't make sense, since it implicitly requires an
address.

> Anyway, doing all in 2.063 beta phase is difficult.

I agree.

> 
> Therefore I'd like to propose that:
> 1. We once fix this "regression" and make the OP code workable in 2.063, by
> merging my patch.

That's probably the easiest thing to do.

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