https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111537

--- Comment #7 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
(In reply to David Malcolm from comment #5)
> Is D correctly building that string_cst?  Are D strings 0-terminated?
Yes, D strings are 0-terminated.

The way I've done it is, the string is constructed using

  build_string(3, "foo")

but the TREE_TYPE is set to `char[4]` so that the terminating 0 is considered.

I'm sure it's like this because either GCC has a tendency to emit strings
side-by-side without the 0 so strlen("foo") could return 20, or there's an
optimization pass for strlen() that would otherwise evaluate strlen("foo") into
2 if I set the type of the literal as `char[3]`.

Reply via email to