[Issue 21316] New: NRVO not triggered for rvalue/ctor call

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 16 07:24:19 UTC 2020


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

          Issue ID: 21316
           Summary: NRVO not triggered for rvalue/ctor call
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: major
          Priority: P3
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: eyal at weka.io

Example program:

  import std.stdio;

  struct S {
      this(int x) { writefln("%s", &this); }
      ~this() { writefln("%s", &this); }
  }

  unittest {
      auto f() { return S(1); }
      auto x = f();
  }

Running results in 2 different this ptrs, showing a copy had occurred:

  dmd -unittest -main -run testnrvo
  7FFE98EAAD20
  7FFE98EAAD48

--


More information about the Digitalmars-d-bugs mailing list