Bug 1916 – segfault on invalid string concat

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-03-12T20:00:00Z
Last change time
2015-06-09T01:14:36Z
Keywords
ice-on-invalid-code, patch
Assigned to
bugzilla
Creator
spam

Comments

Comment #0 by spam — 2008-03-12T20:00:16Z
this invalid piece of code crashes the dmd compiler. [CODE] void main() { string crash = 01 ~ " foo?"; } [/CODE]
Comment #1 by gide — 2008-04-17T07:26:28Z
This looks similar to a BUG 1702 which did get fixed, a later release appears to have re-introduced it.
Comment #2 by clugdbug — 2009-04-01T07:57:45Z
Only segfaults on D2. fog.d(2): Error: incompatible types for ((1) ~ (" foo?")): 'int' and 'immutable( char)[]' fog.d(2): Error: Can only concatenate arrays, not (int ~ immutable(char)[]) fog.d(2): Error: cannot implicitly convert expression ("\x01 foo?") of type int to immutable(char)[] [SEGFAULT]
Comment #3 by clugdbug — 2009-04-14T04:57:17Z
This is indeed the same as bug 1702. A patch to fix this one also fixed 1702. *** This bug has been marked as a duplicate of 1702 ***
Comment #4 by clugdbug — 2009-04-14T06:59:31Z
Oops, 1702 seems to be already fixed. This isn't the same. Here's a simple patch which prevents the segfault. Index: optimize.c =================================================================== --- optimize.c (revision 23) +++ optimize.c (working copy) @@ -456,6 +457,8 @@ Expression *e1old = e1; e1 = e1->optimize(result); e1 = fromConstInitializer(result, e1); + + if (!type->toBasetype()->ty) return this; // Bugzilla 1916 if (e1 == e1old && e1->op == TOKarrayliteral &&
Comment #5 by clugdbug — 2009-05-14T06:56:12Z
Fixed DMD2.030 and 1.045.