www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - What is a dchar ?

reply Cecil Ward <cecil cecilward.com> writes:
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
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
The spec says they are unsigned, so if ldc is using sign extension, that 
is probably a bug.
Jul 25 2023
parent Cecil Ward <cecil cecilward.com> writes:
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