[Issue 23403] New: Segfault when calling auto-generated struct constuctor with __FUNCTION__ or __PRETTY_FUNCTION__

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 10 15:16:29 UTC 2022


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

          Issue ID: 23403
           Summary: Segfault when calling auto-generated struct constuctor
                    with __FUNCTION__ or __PRETTY_FUNCTION__
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andrej.mitrovich at gmail.com

-----
struct Context
{
    string pretty_function;
}

void test(Context ctx = Context(__FUNCTION__))
{
}

void main()
{
    test();
}
-----

> $ dmd test.d
> [test.d(6)] __FUNCTION__: __FUNCTION__
> [1]    1000 illegal hardware instruction (core dumped)  dmd test.d

Also reproducible with __PRETTY_FUNCTION__.

Note that it works OK if `Context` has a hand-written ctor taking a string.

--


More information about the Digitalmars-d-bugs mailing list