D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20477 - incorrect error: cannot implicitly convert expression of type int to dchar
Summary: incorrect error: cannot implicitly convert expression of type int to dchar
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-03 16:52 UTC by Dennis
Modified: 2024-12-13 19:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Dennis 2020-01-03 16:52:39 UTC
```
void main() {
    static assert(is(int:dchar));
    int a = 1114112;
    dchar b = a;
    dchar c = 1114112;
}
```

On variable c it says Error: cannot implicitly convert expression 1114112 of type int to dchar. The value is above `dchar.max`, but since `is(int:dchar)` the error "cannot implicitly convert" is false.

Related: https://issues.dlang.org/show_bug.cgi?id=14627
Comment 1 Dominikus Dittes Scherkl 2020-01-04 15:40:15 UTC
dchar is designed to contain unicode values, which are limited to the range 0x00000000 to 0x0010FFFF == 1114111, so the given literal is outside this range.
Comment 2 dlangBugzillaToGithub 2024-12-13 19:06:40 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19654

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB