D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6988 - char a = 'ä'; should not compile
Summary: char a = 'ä'; should not compile
Status: RESOLVED DUPLICATE of issue 6458
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid, diagnostic
Depends on:
Blocks:
 
Reported: 2011-11-22 09:13 UTC by Andrei Alexandrescu
Modified: 2015-06-09 05:14 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2011-11-22 09:13:42 UTC
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 Trass3r 2011-11-22 12:19:23 UTC
It's more general:

void main()
{
	char a = 'ä'; // compiles fine
}
Comment 2 yebblies 2012-01-31 19:48:05 UTC

*** This issue has been marked as a duplicate of issue 6458 ***