[Issue 19012] New: `scoped` crashes when instantiating an object with `alias this`

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 21 17:00:57 UTC 2018


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

          Issue ID: 19012
           Summary: `scoped` crashes when instantiating an object with
                    `alias this`
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: hauzer.nv at gmail.com

Steps to reproduce: Run https://run.dlang.io/is/etSXLW
Actual results: Crashes with SIGSEGV.
Expected results: Program runs successfully.
Build: DMD64 D Compiler v2.080.1-dirty on Arch Linux 4.17.2-1-zen x86_64

I see that in #5115 Dmitry Olshansky says that `scoped` is basically a failure
and should be officially deprecated in favor of `scope`. Is that true? Note
that I'm a D newbie, so I'm treading on very new ground here.

Code from the link above, for completeness:

import std.typecons;

class A {
    int a;
    alias a this;

    this(const int a) {
        this.a = a;
    }
}

void main() {
    auto a = scoped!A(0);
}

--


More information about the Digitalmars-d-bugs mailing list