[Issue 9051] Passing an immutable global with post-blit to a CTFE function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Nov 26 00:56:26 PST 2012


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



--- Comment #3 from Don <clugdbug at yahoo.com.au> 2012-11-26 00:56:22 PST ---
(In reply to comment #2)
> (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?

Yeah, that's kind of like bug 7988. The calling of this(this) should be part of
the CTFE'd bit. CTFE could cope with it, no problem, it just doesn't get a
chance. BTW if we moved the this(this) into CTFE, the example I posted would
also work!

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