www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23403] New: Segfault when calling auto-generated struct

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 puremagic.com
          Reporter: andrej.mitrovich 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. --
Oct 10 2022