C++ Logo

sg16

Advanced search

Re: [SG16] P2362R0 Make obfuscating wide character literals ill-formed

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 14 Apr 2021 14:21:46 -0700
On Wednesday, 14 April 2021 12:02:18 PDT Peter Brett via SG16 wrote:
> When running clang -target x86_64-win64-msvc, my experiments suggest that
> it's necessary to also pass -fshort-char in order to obtain 16-bit wchar_t.

You've got a bad target there. If you correct it to "x86_64-windows" (the "-
msvc" suffix is unnecessary, but you can use it to pass an MSVC version, like
"-msvc19.6.3") or to "x86_64-mingw", you get 2.

$ cat test.cpp
unsigned x = sizeof(wchar_t);
$ clang -target x86_64-windows -S -o - test.cpp
        .text
        .def @feat.00;
        .scl 3;
        .type 0;
        .endef
        .globl @feat.00
.set @feat.00, 0
        .file "-"
        .data
        .globl "?x@@3IA" # @"?x@@3IA"
        .p2align 2
"?x@@3IA":
        .long 2 # 0x2

        .addrsig
$ clang -target x86_64-mingw -S -o - test.cpp
        .text
        .def @feat.00;
        .scl 3;
        .type 0;
        .endef
        .globl @feat.00
.set @feat.00, 0
        .file "-"
        .data
        .globl x # @x
        .p2align 2
x:
        .long 2 # 0x2

        .addrsig


-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2021-04-14 16:21:51