Thread overview
Invalid string literal in ASM
Oct 01, 2018
dokutoku
Oct 01, 2018
Basile B.
Oct 01, 2018
Basile B.
Oct 04, 2018
dokutoku
October 01, 2018
I get a compiler error when I try to put non-ASCII characters in a string literal in the inline assembler.

Is this part of the specifications?
October 01, 2018
On Monday, 1 October 2018 at 08:14:07 UTC, dokutoku wrote:
> I get a compiler error when I try to put non-ASCII characters in a string literal in the inline assembler.
>
> Is this part of the specifications?

It's not clear, see https://dlang.org/spec/iasm.html#raw_data:

"if an operand is a string literal, it is as if there were length operands, where length is the number of characters in the string"

db "e"; // ok
db "é"; // error

it seems that the second case should be accepted as db 195 db 169

October 01, 2018
On Monday, 1 October 2018 at 09:24:47 UTC, Basile B. wrote:
> On Monday, 1 October 2018 at 08:14:07 UTC, dokutoku wrote:
>> I get a compiler error when I try to put non-ASCII characters in a string literal in the inline assembler.
>>
>> Is this part of the specifications?
>
> It's not clear, see https://dlang.org/spec/iasm.html#raw_data:
>
> "if an operand is a string literal, it is as if there were length operands, where length is the number of characters in the string"
>
> db "e"; // ok
> db "é"; // error
>
> it seems that the second case should be accepted as db 195 db 169

BUG imo. length is 2. "é" should be interpreted as the 2 bytes of its data.
Something with decoding is wrong here.
October 04, 2018
On Monday, 1 October 2018 at 10:45:25 UTC, Basile B. wrote:
> On Monday, 1 October 2018 at 09:24:47 UTC, Basile B. wrote:
>> On Monday, 1 October 2018 at 08:14:07 UTC, dokutoku wrote:
>>> I get a compiler error when I try to put non-ASCII characters in a string literal in the inline assembler.
>>>
>>> Is this part of the specifications?
>>
>> It's not clear, see https://dlang.org/spec/iasm.html#raw_data:
>>
>> "if an operand is a string literal, it is as if there were length operands, where length is the number of characters in the string"
>>
>> db "e"; // ok
>> db "é"; // error
>>
>> it seems that the second case should be accepted as db 195 db 169
>
> BUG imo. length is 2. "é" should be interpreted as the 2 bytes of its data.
> Something with decoding is wrong here.

As a conclusion, is it OK to say DMD bug?