public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3465] d: Don't include terminating null pointer in string expression conversion (PR102185) Date: Sun, 12 Sep 2021 15:46:06 +0000 (GMT) [thread overview] Message-ID: <20210912154606.46AA13858408@sourceware.org> (raw) https://gcc.gnu.org/g:53a4def0dc1aac39d592a0d20e9ec16e8b5574ac commit r12-3465-g53a4def0dc1aac39d592a0d20e9ec16e8b5574ac Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Fri Sep 3 09:34:00 2021 +0200 d: Don't include terminating null pointer in string expression conversion (PR102185) This gets re-added by the ExprVisitor when lowering StringExp back into a STRING_CST during the code generator pass. PR d/102185 gcc/d/ChangeLog: * d-builtins.cc (d_eval_constant_expression): Don't include terminating null pointer in string expression conversion. gcc/testsuite/ChangeLog: * gdc.dg/pr102185.d: New test. Diff: --- gcc/d/d-builtins.cc | 2 +- gcc/testsuite/gdc.dg/pr102185.d | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc index ab39d69c294..33347a14c67 100644 --- a/gcc/d/d-builtins.cc +++ b/gcc/d/d-builtins.cc @@ -380,7 +380,7 @@ d_eval_constant_expression (const Loc &loc, tree cst) else if (code == STRING_CST) { const void *string = TREE_STRING_POINTER (cst); - size_t len = TREE_STRING_LENGTH (cst); + size_t len = TREE_STRING_LENGTH (cst) - 1; return StringExp::create (loc, CONST_CAST (void *, string), len); } else if (code == VECTOR_CST) diff --git a/gcc/testsuite/gdc.dg/pr102185.d b/gcc/testsuite/gdc.dg/pr102185.d new file mode 100644 index 00000000000..39823a3c556 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr102185.d @@ -0,0 +1,7 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102185 +// { dg-do compile } + +static assert(__traits(getTargetInfo, "floatAbi").length == 0 || + __traits(getTargetInfo, "floatAbi") == "hard" || + __traits(getTargetInfo, "floatAbi") == "soft" || + __traits(getTargetInfo, "floatAbi") == "softfp");
reply other threads:[~2021-09-12 15:46 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210912154606.46AA13858408@sourceware.org \ --to=ibuclaw@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).