digitalmars.D.learn - What is a dchar ?
- Cecil Ward (6/6) Jul 25 2023 Is a dchar a signed 32-bit number? LDC seems to think so, as I
- Richard (Rikki) Andrew Cattermole (2/2) Jul 25 2023 The spec says they are unsigned, so if ldc is using sign extension, that...
- Cecil Ward (9/11) Jul 27 2023 My fault, I reread the code and the sign-extension applies to
Is a dchar a signed 32-bit number? LDC seems to think so, as I spotted it in Compiler Explorer sign-extending from 32 to 64-bits for some very odd reason. Do we really want it to be signed? (Please answer ‘no’, as this could lead to some bugs, although the range of legitimate Unicode code points is quite limited, being only, what, 17 * 65536 roughly.)
Jul 25 2023
The spec says they are unsigned, so if ldc is using sign extension, that is probably a bug.
Jul 25 2023
On Wednesday, 26 July 2023 at 01:56:28 UTC, Richard (Rikki) Andrew Cattermole wrote:The spec says they are unsigned, so if ldc is using sign extension, that is probably a bug.My fault, I reread the code and the sign-extension applies to something else, coincidentally right where I was looking at this. It uses signed 32-bit displacements in a case/switch table of offsets into the code segment, and that was what mislead me. It could have used unsigned displacements but then all the labels in the code would have to be above the reference base point, and this allows +/- offsets to anywhere. So my apologies.
Jul 27 2023