https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111537
--- Comment #8 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Looking at C++ FE, I see they construct the string literal using
build_string (4, "foo")
because I can see the terminating 0 in the pretty-printed string.
---
<string_cst 0x7ffff717b988
type <array_type 0x7ffff717d0a8
type <integer_type 0x7ffff743b5e8 char readonly sizes-gimplified type_6
QI
size <integer_cst 0x7ffff742a258 constant 8>
unit-size <integer_cst 0x7ffff742a270 constant 1>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff743b5e8 precision:8 min <integer_cst 0x7ffff742a2a0 -128> max
<integer_cst 0x7ffff742a2d0 127>
pointer_to_this <pointer_type 0x7ffff743b690>>
type_6 BLK
size <integer_cst 0x7ffff75ec408 constant 96>
unit-size <integer_cst 0x7ffff75ec120 constant 12>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff717d0a8
domain <integer_type 0x7ffff717de70 type <integer_type 0x7ffff7430000
sizetype>
type_6 DI
size <integer_cst 0x7ffff742a168 constant 64>
unit-size <integer_cst 0x7ffff742a180 constant 8>
align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff717de70 precision:64 min <integer_cst 0x7ffff742a198 0> max <integer_cst
0x7ffff75ec288 11>>
pointer_to_this <pointer_type 0x7ffff717d498>>
readonly constant static "hello world\000">
---
I see in the olden days when D sat outside of GCC, this is what was done too.
https://github.com/D-Programming-GDC/gdc/commit/b9d36fc9d71ec4122d1c986599d87c6cb91ca55c
This might have been accidentally removed by another contributor in an apparent
drive-by search and replace of a specific pattern.
https://github.com/D-Programming-GDC/gdc/commit/f8a05f41cb756ef7ed2b1d8b1d33eb8f815421a5