Bug 2176 – Assertion failure: 'sz == es2->sz' on line 1339 in file 'constfold.c' (concatenating strings of different types)
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2008-06-25T23:50:00Z
Last change time
2014-02-24T15:59:55Z
Keywords
ice-on-invalid-code, patch
Assigned to
bugzilla
Creator
jarrett.billingsley
Comments
Comment #0 by jarrett.billingsley — 2008-06-25T23:50:53Z
OH COME ON. HONESTLY.
auto s = "foo"d ~ "bar"c;
Comment #1 by davidl — 2008-06-26T00:30:23Z
constfold.c :
789 or so
else if (e1->op == TOKstring && e2->op == TOKstring)
{ StringExp *es1 = (StringExp *)e1;
+++ if (sz != es2.sz)
+++ {
+++ error("cannot concatnate two different string type");
+++ return e;
+++ }
--- assert(es1->sz == es2->sz);
1339 line or so
Type *t;
size_t len = es1->len + es2->len;
int sz = es1->sz;
+++ if (sz != es2.sz)
+++ {
+++ error("cannot concatnate two different string type");
+++ return e;
+++ }
--- assert(es1->sz == es2->sz);
Comment #2 by davidl — 2008-06-26T00:35:03Z
oh sorry, the patch for line 789 or so should be something
else if (e1->op == TOKstring && e2->op == TOKstring)
{ StringExp *es1 = (StringExp *)e1;
+++ if (sz != es2.sz)
+++ {
+++ cmp = 1;
+++ }
--- assert(es1->sz == es2->sz);
and another test case is:
pragma(msg, "foo"d == "bar"c? "A":"B");
this can trigger the Equal assertion failure