public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "simark at simark dot ca" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug exp/26875] Incorrect value printed for address of first element of zero-length array
Date: Fri, 20 Nov 2020 22:25:12 +0000	[thread overview]
Message-ID: <bug-26875-4717-yEjgDA04Ts@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-26875-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=26875

--- Comment #12 from Simon Marchi <simark at simark dot ca> ---
(In reply to Tom de Vries from comment #11)
> (In reply to Simon Marchi from comment #7)
> > I am not able to reproduce.  In my version of the compiled test case, both
> > bounds are const:
> > 
> > (top-gdb) p type->bounds ()->low.kind ()
> > $4 = PROP_CONST
> > (top-gdb) p type->bounds ()->high.kind ()
> > $5 = PROP_CONST
> > 
> > What compiler do you use to build the test case?
> 
> Gcc 7.5.0

Thanks, I see the failure with gcc 7.

> > So I presume GDB translates that to two constant bounds with value 0.  What
> > does it look like in yours?
> > 
> > I stumbled on a similar problem and filed this bug here, they are likely
> > related:
> > 
> > https://sourceware.org/bugzilla/show_bug.cgi?id=26901
> > 
> > I have this patch series in the pipeline that I made to address 26901:
> > 
> > https://review.lttng.org/c/binutils-gdb/+/4399/4
> > 
> 
> Ah, thanks for the pointer, I'll take a look.

The patches are not commented at all now, but the idea is to be able to fetch
the low and high bounds separately, not all or nothing like it is now.  Here,
we only care about the low bound, so we only get that one, and ignore the high
bound (which is unknown).

> 
> > If/when I am able to reproduce this (26875) bug, I can check if that helps
> > with it too.
> 
> That would be great.

The failure goes away with these patches applied.

The only thing that bugs me is that some part of the code assumes that a bound
of "-1" means an unknown bound.  It seems to me that if we use gdb::optional,
we don't need that: an empty optional means an unknown bound.  So we would need
to go through all the users to see we if need the "set to -1" vs "empty
optional" disctinction or not.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2020-11-20 22:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13  9:32 [Bug exp/26875] New: " vries at gcc dot gnu.org
2020-11-13 10:33 ` [Bug exp/26875] " vries at gcc dot gnu.org
2020-11-13 10:53 ` vries at gcc dot gnu.org
2020-11-13 14:47 ` vries at gcc dot gnu.org
2020-11-13 16:52 ` vries at gcc dot gnu.org
2020-11-14 11:45 ` vries at gcc dot gnu.org
2020-11-14 12:04 ` vries at gcc dot gnu.org
2020-11-20 18:00 ` simark at simark dot ca
2020-11-20 18:03 ` simark at simark dot ca
2020-11-20 18:07 ` simark at simark dot ca
2020-11-20 18:17 ` simark at simark dot ca
2020-11-20 22:16 ` vries at gcc dot gnu.org
2020-11-20 22:25 ` simark at simark dot ca [this message]
2020-11-23 16:25 ` simark at simark dot ca
2020-12-09 18:53 ` cvs-commit at gcc dot gnu.org
2020-12-09 21:34 ` cvs-commit at gcc dot gnu.org
2020-12-09 22:11 ` simark at simark dot ca
2021-10-13 14:22 ` vries 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-26875-4717-yEjgDA04Ts@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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).