Bug 6988 – char a = 'ä'; should not compile

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-11-22T09:13:00Z
Last change time
2015-06-09T05:14:58Z
Keywords
accepts-invalid, diagnostic
Assigned to
nobody
Creator
andrei

Comments

Comment #0 by andrei — 2011-11-22T09:13:42Z
unittest { char[] chars = ['à','è','ì']; assert(chars == "àèì"); } The assertion fails for the obvious reason there's no room in chars for the multibyte characters. The initialization should not compile because it attempts to truncate wide characters into meaningless bytes.
Comment #1 by hoganmeier — 2011-11-22T12:19:23Z
It's more general: void main() { char a = 'ä'; // compiles fine }
Comment #2 by yebblies — 2012-01-31T19:48:05Z
*** This issue has been marked as a duplicate of issue 6458 ***