Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla

Bug 281

Summary: NRVO tests behave different than in DMD
Product: GDC Reporter: Eugene Wissner <belka>
Component: gdcAssignee: Iain Buclaw <ibuclaw>
Status: NEW ---    
Severity: minor    
Priority: ---    
Version: development   
Hardware: All   
OS: All   

Description Eugene Wissner 2017-12-10 14:13:06 CET
extern (C) int printf(const(char*) fmt, ...);
/**********************************/
// 13089

struct S13089
{
    @disable this(this);    // non nothrow
}

void* p13089;

S13089[1000] foo13089() nothrow
{
    typeof(return) data;
    p13089 = &data;
    return data;
}

void main()
{
    immutable data = foo13089();
    assert(p13089 == &data);
}

The assertion holds in DMD but fails in GCC. The question is whether it is something should be changed.

References:
http://forum.dlang.org/post/gverkczeotvadwmdowdl@forum.dlang.org
https://dlang.org/glossary.html#nrvo
https://github.com/D-Programming-GDC/GDC/pull/573