public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug analyzer/111537] ICE: in set_cell_span, at text-art/table.cc:148 with D front-end and -fanalyzer
Date: Wed, 11 Oct 2023 18:27:03 +0000	[thread overview]
Message-ID: <bug-111537-4-dGNyzsynKF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111537-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
It's complaining about the read from the string literal.

If I change the string in the reproducer from "hello world" to "foo", I see:

(gdb) pt string_cst
 <string_cst 0x7fffea76f738
    type <array_type 0x7fffea78a150
        type <integer_type 0x7fffea772930 char readonly unsigned QI
            size <integer_cst 0x7fffea644eb8 constant 8>
            unit-size <integer_cst 0x7fffea644ed0 constant 1>
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea772930 precision:8 min <integer_cst 0x7fffea6624c8 0> max <integer_cst
0x7fffea662450 255>
            pointer_to_this <pointer_type 0x7fffea78a000>>
        SI
        size <integer_cst 0x7fffea662018 constant 32>
        unit-size <integer_cst 0x7fffea662030 constant 4>
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea78a150
        domain <integer_type 0x7fffea672150 type <integer_type 0x7fffea65e000
sizetype>
            DI
            size <integer_cst 0x7fffea644dc8 constant 64>
            unit-size <integer_cst 0x7fffea644de0 constant 8>
            align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffea672150 precision:64 min <integer_cst 0x7fffea644df8 0> max <integer_cst
0x7fffea662558 3>>
        pointer_to_this <p

Looking at TREE_STRING_LENGTH:

/* In a STRING_CST */
/* In C terms, this is sizeof, not strlen.  */
#define TREE_STRING_LENGTH(NODE) (STRING_CST_CHECK (NODE)->string.length)

(gdb) p string_cst->string.length
$36 = 3

The analyzer is using this for determining the validly accessible size of the
string, which it determines is 3 bytes:

(gdb) call valid_bits.dump(true)
bytes 0-2

whereas the read is of 4 bytes:
(gdb) call actual_bits.dump(true)
bytes 0-3

Is D correctly building that string_cst?  Are D strings 0-terminated?

  parent reply	other threads:[~2023-10-11 18:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22 10:31 [Bug analyzer/111537] New: " ibuclaw at gdcproject dot org
2023-10-10 21:51 ` [Bug analyzer/111537] " dmalcolm at gcc dot gnu.org
2023-10-11 16:33 ` ibuclaw at gdcproject dot org
2023-10-11 17:47 ` dmalcolm at gcc dot gnu.org
2023-10-11 17:48 ` dmalcolm at gcc dot gnu.org
2023-10-11 18:27 ` dmalcolm at gcc dot gnu.org [this message]
2023-10-11 18:29 ` dmalcolm at gcc dot gnu.org
2023-10-11 20:05 ` ibuclaw at gdcproject dot org
2023-10-11 20:49 ` ibuclaw at gdcproject dot org
2023-10-13 16:25 ` ibuclaw at gdcproject dot org
2023-10-13 16:43 ` [Bug d/111537] " ibuclaw at gcc dot gnu.org
2023-10-14 12:22 ` cvs-commit at gcc dot gnu.org
2023-10-14 12:27 ` ibuclaw at gcc dot gnu.org

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=bug-111537-4-dGNyzsynKF@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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: link
Be 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).