[Issue 9051] Passing an immutable global with post-blit to a CTFE function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 21 10:49:20 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9051
--- Comment #2 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2012-11-21 10:49:17 PST ---
(In reply to comment #1)
> The error message is not coming from CTFE. Here's a simple case from a comment
> in the compiler source code (declaration.c):
>
> /* The problem is the following code:
> * struct CopyTest {
> * double x;
> * this(double a) { x = a * 10.0;}
> * this(this) { x += 2.0; }
> * }
> * const CopyTest z = CopyTest(5.3); // ok
> * const CopyTest w = z; // not ok, postblit not run
> * static assert(w.x == 55.0);
> * because the postblit doesn't get run on the initialization of w.
> */
>
> I think that if we didn't call this(this), wrong code would result.
I agree in general. And But given that getMeASet(uint[] arr) is an r-value.
Surely the result of it should be just moved?
The other thought is: can't this(this) be run at compile-time then? What are
limitations?
> There is at least a diagnostic bug here - if it must behave this way, the code
> that creates the comma expression should be issuing the error.
>
> Interestingly, if you move it inside a function, the result is different:
>
The same thing happens if you try passing set by reference be it const or
otherwise.
> void foo()
> {
> pragma(msg, getSecond(set));
> }
>
> qqq.d(19): Error: static variable set cannot be referenced at compile time
> qqq.d(19): called from here: __cpcttmp6.__cpctor(set)
> qqq.d(19): called from here: getSecond((const const(Set) __cpcttmp6 =
> __cpcttmp6.__cpctor(set);
> , __cpcttmp6))
--
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