[Issue 20324] New: Calling __traits(getUnitTests) on a template causes compiler segfault

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Oct 26 12:38:23 UTC 2019


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

          Issue ID: 20324
           Summary: Calling __traits(getUnitTests) on a template causes
                    compiler segfault
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: carlin.stpierre at protonmail.com

Compiler segfaults because of the following code:


```
module segfault;

template Foo() {
        unittest {}
}

void bar() {
        foreach(member; __traits(derivedMembers, segfault)) {
                alias a = __traits(getUnitTests, __traits(getMember, segfault,
member));
        }
}
```

Compiler output:
```
$ dmd -v -c -unittest segfault.d 
predefs   DigitalMars Posix linux ELFv1 CRuntime_Glibc CppRuntime_Gcc
LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC
unittest assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary    dmd
version   v2.088.0
config    /etc/dmd.conf
DFLAGS    -I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import
-L-L/usr/lib/x86_64-linux-gnu -L--export-dynamic -fPIC
parse     segfault
importall segfault
import    object        (/usr/include/dmd/druntime/import/object.d)
import    core.internal.array.appending
(/usr/include/dmd/druntime/import/core/internal/array/appending.d)
import    core.internal.array.comparison       
(/usr/include/dmd/druntime/import/core/internal/array/comparison.d)
import    core.internal.array.equality 
(/usr/include/dmd/druntime/import/core/internal/array/equality.d)
import    core.internal.array.casting  
(/usr/include/dmd/druntime/import/core/internal/array/casting.d)
import    core.internal.array.concatenation    
(/usr/include/dmd/druntime/import/core/internal/array/concatenation.d)
import    core.internal.array.construction     
(/usr/include/dmd/druntime/import/core/internal/array/construction.d)
import    core.internal.array.capacity 
(/usr/include/dmd/druntime/import/core/internal/array/capacity.d)
import    core.internal.hash   
(/usr/include/dmd/druntime/import/core/internal/hash.d)
import    core.internal.traits 
(/usr/include/dmd/druntime/import/core/internal/traits.d)
import    core.internal.convert
(/usr/include/dmd/druntime/import/core/internal/convert.d)
semantic  segfault
semantic2 segfault
semantic3 segfault
Segmentation fault (core dumped)
```

--


More information about the Digitalmars-d-bugs mailing list