www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11224] New: Inlining stops NRVO

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11224

           Summary: Inlining stops NRVO
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg gmail.com> 2013-10-11 03:21:24 PDT ---
Test code:
------------
extern(C) int printf(const char*, ...);
struct S
{
    this(int) { printf("ctor &this = %p\n", &this); }
    int num;
}
S foo()
{
    S s = S(1);
    printf("foo  &this = %p\n", &s);
    return s;
}
void main()
{
    auto s = foo();
    printf("main &this = %p\n", &s);
}


Output:
------------
$ dmd -run test
ctor &this = 0012FE20
foo  &this = 0012FE20
main &this = 0012FE20

------------
$ dmd -inline -run test
ctor &this = 0012FE1C
foo  &this = 0012FE1C
main &this = 0012FE18   // variable is moved!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 11 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11224


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-10-11 03:24:11 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2592

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 11 2013