Bug 8601 – CTFE Assertion failure (interpret.c) on dstring[].toUpper

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2012-08-30T10:58:00Z
Last change time
2015-06-09T05:11:56Z
Keywords
CTFE, ice
Assigned to
nobody
Creator
callumenator

Comments

Comment #0 by callumenator — 2012-08-30T10:58:03Z
import std.string, std.traits, std.conv; enum E {one, two} enum dstring[] fields = [EnumMembers!E].to!(dstring[]); pragma(msg, fields[0].toUpper); Gives: Assertion failure: '((ArrayLiteralExp *)se->e1)->ownedByCtfe' on line 7009 in file 'interpret.c' DMD32 2.060 Windows 7 Replace dstring[] with string[] and the error changes to a compile-time error in std.string.toUpper, which also should not occur (far as I can tell).
Comment #1 by clugdbug — 2012-09-03T23:39:08Z
Reduced test case: dchar bug8601(dstring s) { dstring w = s[1..$]; return w[0]; } enum dstring e8601 = [cast(dchar)'o', 'n']; static assert(bug8601(e8601));
Comment #2 by clugdbug — 2012-09-05T00:04:56Z
The dstring ICE is entirely spurious, the assert is wrong and should be removed. The situation with string is a completely unrelated bug; it's a constant-folding issue. A string initialized with an array literal doesn't support ~= of a character of a larger size. Here's a reduced case for that bug. bool bug8601b() { string r = ['x', 'q']; dchar c = 'ü'; r ~= c; assert(r == "xqü"); return true; } static assert(bug8601b()); bug.d(8): Error: Cannot interpret r ~= c at compile time This is interesting because an array literal containing multiple code point characters cannot normally exist. -------- void main() { string yyy = ['ü', 'q']; // ok } string xxx = ['ü', 'q']; // fails -------- g.d(8): Error: cannot implicitly convert expression ('\xfc') of type wchar to immutable(char)
Comment #3 by clugdbug — 2012-09-17T01:01:49Z
I split off the unrelated non-ICE bug to a new bug 8659.
Comment #4 by github-bugzilla — 2012-10-20T19:26:01Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c5e0be499bf9d1ecab59845409e1b8830e7c8376 Fix bug 8601: CTFE ICE on dstring[].toUpper This error is spurious, the assert is incorrect.