www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23007] New: importC: dmd segfaults for extra braces in array

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

          Issue ID: 23007
           Summary: importC: dmd segfaults for extra braces in array
                    initializer
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ice, ImportC
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: duser neet.fi
                CC: duser neet.fi

int x[1] = {{1}};

---
Program received signal SIGSEGV, Segmentation fault.
0x00005555558bb178 in visitC (this=0x7fffffffcf28, ci=0x7ffff757f870) at
src/dmd/todt.d:251
251             array(ci.type,
cast(size_t)ci.type.isTypeSArray().dim.toInteger());
(gdb) i lo
i = 0
dil = {{designatorList = 0x0, initializer = 0x7ffff757f840}}
(gdb) i ar
this = 0x7fffffffcf28
ci = 0x7ffff757f870
(gdb) bt

src/dmd/todt.d:251

(init=0x7ffff757f870, dtb=...) at src/dmd/todt.d:261

at src/dmd/todt.d:115

(init=0x7ffff6d5a680, dtb=...) at src/dmd/todt.d:259

toObjFile::ToObjFile::initializerToDt(VarDeclaration*, DtBuilder&)
(vd=0x7ffff757f930, dtb=...) at src/dmd/toobj.d:865

(this=0x7fffffffd2b0, vd=0x7ffff757f930) at src/dmd/toobj.d:631

(this=0x7ffff757f930, v=0x7fffffffd2b0) at src/dmd/declaration.d:1653

(this=0x7fffffffd2b0, ad=0x7ffff757fa60) at src/dmd/toobj.d:748

(this=0x7fffffffd2b0, s=0x7ffff757fa60) at src/dmd/parsetimevisitor.d:71

(this=0x7ffff757fa60, v=0x7fffffffd2b0) at src/dmd/attrib.d:434

multiobj=false) at src/dmd/toobj.d:1008

multiobj=false) at src/dmd/glue.d:522

const(char)*[], const(char)[], const(char)[], bool, bool, bool, bool, bool)
(modules=..., libmodules=..., libname=..., objdir=..., lib=false, obj=true,
oneobj=false, multiobj=false, verbose=false) at src/dmd/glue.d:137

dmd.globals.Param) (argc=3, argv=0x7fffffffdd28, params=...) at
src/dmd/mars.d:574

---

(not visible from this output but "ci.type.isTypeSArray()" returns null in the
expression)

line at current commit:
https://github.com/dlang/dmd/blob/863fec775e2dd8b8f4788849d7b8923b70dcf279/src/dmd/todt.d#L251

--
Apr 10 2022