Bug 24406 – wrong signess of comparison with -O and byte-casted char

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-02-23T10:08:08Z
Last change time
2024-12-13T19:33:25Z
Assigned to
No Owner
Creator
Andrei Horodniceanu
Moved to GitHub: dmd#20405 →

Comments

Comment #0 by a.horodniceanu — 2024-02-23T10:08:08Z
Reduced from https://github.com/Pure-D/serve-d/blob/master/lsp/source/served/lsp/textdocumentmanager.d#L1309: ``` void main () { char c = (() => cast(char)47)(); // c == '/' assert(cast(byte)c >= -0x40); } ``` ``` $ dmd -O -run main.d [email protected](3): Assertion failure ---------------- ??:? _d_assertp [0x55635be3f818] ??:? _Dmain [0x55635be3f76b] ``` $ dmd -run main.d <no error> ``` Tested against master. The code generated is: ``` 0x0000555555597748 <+0>: push %rbp 0x0000555555597749 <+1>: mov %rsp,%rbp 0x000055555559774c <+4>: rex.W call *0x4b7fd(%rip) # 0x5555555e2f50 0x0000555555597753 <+11>: cmp $0xc0,%al 0x0000555555597755 <+13>: jb 0x55555559775b <_Dmain+19> 0x0000555555597757 <+15>: xor %eax,%eax 0x0000555555597759 <+17>: pop %rbp 0x000055555559775a <+18>: ret 0x000055555559775b <+19>: mov $0x3,%esi 0x0000555555597760 <+24>: lea 0x398b9(%rip),%rdi # 0x5555555d1020 <_TMP0> 0x0000555555597767 <+31>: call 0x5555555977d0 <_d_assertp> 0x000055555559776c <+36>: pop %rbp 0x000055555559776d <+37>: ret ``` The problem is with `jb 0x55555559775b <_Dmain+19>` since the comparison should be signed.
Comment #1 by robert.schadek — 2024-12-13T19:33:25Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20405 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB