www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22239] New: Can't migrate from postblits if they are used

https://issues.dlang.org/show_bug.cgi?id=22239

          Issue ID: 22239
           Summary: Can't migrate from postblits if they are used without
                    frame pointer
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: Ajieskola gmail.com

So, postblits are considered a legacy construct that should be migrated to copy
constructors. However, there is an instance where that cannot be done:

---
struct PostBlitted(alias al){
  this(this){}
  void x(){} //a member function so that an instance contains a frame pointer
}

struct CopyConstructed(alias al){
  this(ref typeof(this)){};
  void x(){} //a member function so that an instance contains a frame pointer
}

void main(){
  PostBlitted!(x => x) a;
  CopyConstructed!(x => x) b;

  a.f; //compiles
  b.f; //does not
}

void f(T)(T x){
  T y = x;
}
---

There should be a way to define a copy constructor so that it works even when
the caller does not have a frame pointer for the new struct instance.

--
Aug 25