www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20934] New: preview=dtorfields segfaults for struct template

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

          Issue ID: 20934
           Summary: preview=dtorfields segfaults for struct template with
                    disabled default constructor
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: moonlightsentinel disroot.org

This code segfaults when compiled with -preview=dtorfields:

=========================
struct Array
{
    ~this() {}
}

struct CyclicArray()
{
    Array array;
     disable this();
}

auto heapArray = CyclicArray!()();
=========================

dmd -c -o- cyclic_array.d
cyclic_array.d(12): Error: constructor
cyclic_array.CyclicArray!().CyclicArray.this cannot be used because it is
annotated with  disable
cyclic_array.d(12): Error: this cannot be interpreted at compile time, because
it has no available source code

dmd -c -o- preview=dtorfields cyclic_array.d
Segmentation fault (core dumped)




Running in gdb shows that it tries to do semantic analysis on the missing body
of CyclicArrays disabled dtor:

gdb generated/linux/debug/64/dmd -batch -ex "run -c -o- -preview=dtorfields
cyclic_array.d" -ex "bt" &> gdb.log

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000000008182b6c in Statement::isCompoundStatement() (this=0x0) at
src/dmd/statement.d:424
424         inout(CompoundStatement)    isCompoundStatement()    { return stmt
== STMT.Compound    ? cast(typeof(return))this : null; }


src/dmd/statement.d:424

_D3dmd12statementsem15semanticNoScopeFCQBl9statement9StatementPSQCk6dscope5ScopeZQBr
(s=0x0, sc=0x7ffffddea4b0) at src/dmd/statementsem.d:4318

_D3dmd12statementsem13semanticScopeFCQBj9statement9StatementPSQCi6dscope5ScopeQBqQBtZQBx
(s=0x0, sc=0x7ffffdde98b0, sbreak=0x0, scontinue=0x0) at
src/dmd/statementsem.d:4336

(this=0x7ffffffe90d0, tcs=0x7ffffdde9ef0) at src/dmd/statementsem.d:3826

(this=0x7ffffdde9ef0, v=0x7ffffffe90d0) at src/dmd/statement.d:1980

(s=0x7ffffdde9ef0, sc=0x7ffffdde98b0) at src/dmd/statementsem.d:127

(this=0x7ffffffea368, funcdecl=0x7ffffdde7750) at src/dmd/semantic3.d:577

(this=0x7ffffffea368, ctor=0x7ffffdde7750) at src/dmd/semantic3.d:1407

(this=0x7ffffdde7750, v=0x7ffffffea368) at src/dmd/func.d:3545

sc=0x7ffffdde80d0) at src/dmd/semantic3.d:81

(this=0x7ffffdde7750) at src/dmd/func.d:455

(this=0x7ffffdde7750) at src/dmd/func.d:429

(this=0x7ffffffea6a0, exp=0x7ffffdde9b00) at src/dmd/expressionsem.d:6212

v=0x7ffffffea6a0) at src/dmd/expression.d:4713

(e=0x7ffffdde9b00, sc=0x7fffff6b7d40) at src/dmd/expressionsem.d:11391

_D3dmd13expressionsem11unaSemanticFCQBi10expression6UnaExpPSQCg6dscope5ScopeZCQCyQBq10Expression
(e=0x7ffffdde9b50, sc=0x7fffff6b7d40) at src/dmd/expressionsem.d:11337

(this=0x7ffffffeb760, exp=0x7ffffdde9b50) at src/dmd/expressionsem.d:4311

v=0x7ffffffeb760) at src/dmd/expression.d:4970

(e=0x7ffffdde9b50, sc=0x7fffff6b7d40) at src/dmd/expressionsem.d:11391

(this=0x7ffffffec7f0, exp=0x7fffff6b7960) at src/dmd/expressionsem.d:4437

v=0x7ffffffec7f0) at src/dmd/expression.d:4970

(e=0x7fffff6b7960, sc=0x7fffff6b7d40) at src/dmd/expressionsem.d:11391

_D3dmd7initsem9inferTypeFCQy4init11InitializerPSQBu6dscope5ScopeZ8visitExpMFCQCxQCa14ExpInitializerZQCx
(init=0x7fffff6b79e0) at src/dmd/initsem.d:644

_D3dmd7initsem9inferTypeFCQy4init11InitializerPSQBu6dscope5ScopeZQBo
(init=0x7fffff6b79e0, sc=0x7fffff6b7d40) at src/dmd/initsem.d:702

(this=0x7ffffffed308, dsym=0x7fffff6b7a10) at src/dmd/dsymbolsem.d:822

(this=0x7fffff6b7a10, v=0x7ffffffed308) at src/dmd/declaration.d:1646

(dsym=0x7fffff6b7a10, sc=0x7fffff6b7d40) at src/dmd/dsymbolsem.d:564

_D3dmd10dsymbolsem22DsymbolSemanticVisitor5visitMRCQBx7dmodule6ModuleZ__T9__lambda2TCQDf7dsymbol7DsymbolZQBgMFQBaZv
(s=0x7fffff6b7a10) at src/dmd/dsymbolsem.d:2258

_D3dmd7dsymbol14foreachDsymbolFPSQBf4root5array__T5ArrayTCQCeQCd7DsymbolZQxMDFQvZvZv
(symbols=0x7fffff6b6570, dg=...) at src/dmd/dsymbol.d:98

(this=0x7ffffffed438, m=0x7fffff6b5300) at src/dmd/dsymbolsem.d:2255

v=0x7ffffffed438) at src/dmd/dmodule.d:1464

(dsym=0x7fffff6b5300, sc=0x0) at src/dmd/dsymbolsem.d:564

(argc=5, argv=0x7ffffffee008, params=...) at src/dmd/mars.d:564


--
Jun 15