http://d.puremagic.com/issues/show_bug.cgi?id=4389


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
            Summary|CTFE: Appending dchar to    |ICE(constfold.c,
                   |empty string creates        |expression.c), or wrong
                   |invalid string.             |code: string~=dchar in CTFE


--- Comment #1 from Don <clugd...@yahoo.com.au> 2010-11-23 00:56:25 PST ---
Actually constant folding of string ~= dchar is ALWAYS wrong, even if the
string is non-empty. All these tests fail. It can also cause an
ICE(constfold.c) if you attempt a further concatenation, or ICE(expression.c)
if it is mixed in (bug 3490).

It happens because string ~= dchar is treated specially in the backend, but not
in constfold.c.

---------

int bug4389()
{    
    string s;
    dchar c = '\u2348';
    s ~= c;
    assert(s.length==3);
    dchar d = 'D';
    s ~= d;
    assert(s.length==4);
    s = "";
    s ~= c;
    assert(s.length==3);
    s ~= d;
    assert(s.length==4);
    string z;
    wchar w = '\u0300';
    z ~= w;
    assert(z.length==2);
    z = "";
    z ~= w;
    assert(z.length==2);
    return 1;
}

static assert(bug4389());

// ICE(constfold.c)
int ice4389()
{
    string s;
    dchar c = '\u2348';
    s ~= c;
    s = s ~ "xxx";
   return 1; 
}

static assert(ice4389());

// ICE(expression.c)
string ice4390()
{
    string s;
    dchar c = '`';
    s ~= c;
    s ~= c;
   return s; 
}

static assert(mixin(ice4390()) == ``);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to