public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/24318] GDB prints the wrong value
       [not found] <bug-24318-4717@http.sourceware.org/bugzilla/>
@ 2020-04-07 19:05 ` ssbssa at sourceware dot org
  2020-04-07 20:29 ` jbrejon at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: ssbssa at sourceware dot org @ 2020-04-07 19:05 UTC (permalink / raw)
  To: gdb-prs

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

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org

--- Comment #1 from Hannes Domani <ssbssa at sourceware dot org> ---
(In reply to e from comment #0)
> main.c :
> uint64_t * tab;
> 
> test.c :
> extern uint64_t tab[];

This looks like undefined behavior to me.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug gdb/24318] GDB prints the wrong value
       [not found] <bug-24318-4717@http.sourceware.org/bugzilla/>
  2020-04-07 19:05 ` [Bug gdb/24318] GDB prints the wrong value ssbssa at sourceware dot org
@ 2020-04-07 20:29 ` jbrejon at gmail dot com
  2020-04-07 20:38 ` ssbssa at sourceware dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: jbrejon at gmail dot com @ 2020-04-07 20:29 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from e <jbrejon at gmail dot com> ---
(In reply to Hannes Domani from comment #1)
> (In reply to e from comment #0)
> > main.c :
> > uint64_t * tab;
> > 
> > test.c :
> > extern uint64_t tab[];
> 
> This looks like undefined behavior to me.

I believe the C standard is not the issue here.
Its about gdb consistency.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug gdb/24318] GDB prints the wrong value
       [not found] <bug-24318-4717@http.sourceware.org/bugzilla/>
  2020-04-07 19:05 ` [Bug gdb/24318] GDB prints the wrong value ssbssa at sourceware dot org
  2020-04-07 20:29 ` jbrejon at gmail dot com
@ 2020-04-07 20:38 ` ssbssa at sourceware dot org
  2020-04-07 21:40 ` jbrejon at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: ssbssa at sourceware dot org @ 2020-04-07 20:38 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Hannes Domani <ssbssa at sourceware dot org> ---
(In reply to e from comment #2)
> (In reply to Hannes Domani from comment #1)
> > (In reply to e from comment #0)
> > > main.c :
> > > uint64_t * tab;
> > > 
> > > test.c :
> > > extern uint64_t tab[];
> > 
> > This looks like undefined behavior to me.
> 
> I believe the C standard is not the issue here.
> Its about gdb consistency.

How could there be consistency when tab isn't consistent the same type
everywhere?

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug gdb/24318] GDB prints the wrong value
       [not found] <bug-24318-4717@http.sourceware.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-04-07 20:38 ` ssbssa at sourceware dot org
@ 2020-04-07 21:40 ` jbrejon at gmail dot com
  2023-08-03 16:06 ` tromey at sourceware dot org
  2023-08-03 17:44 ` jbrejon at gmail dot com
  5 siblings, 0 replies; 6+ messages in thread
From: jbrejon at gmail dot com @ 2020-04-07 21:40 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from e <jbrejon at gmail dot com> ---
(In reply to Hannes Domani from comment #3)
> (In reply to e from comment #2)
> > (In reply to Hannes Domani from comment #1)
> > > (In reply to e from comment #0)
> > > > main.c :
> > > > uint64_t * tab;
> > > > 
> > > > test.c :
> > > > extern uint64_t tab[];
> > > 
> > > This looks like undefined behavior to me.
> > 
> > I believe the C standard is not the issue here.
> > Its about gdb consistency.
> 
> How could there be consistency when tab isn't consistent the same type
> everywhere?

My original post contains two experiments in which the same exact code is
executed. In those experiments GDB does not prints the same values for the same
elements at the same moment.
Same code executed (consistentcy), not the same output (unconsistency).

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug gdb/24318] GDB prints the wrong value
       [not found] <bug-24318-4717@http.sourceware.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-04-07 21:40 ` jbrejon at gmail dot com
@ 2023-08-03 16:06 ` tromey at sourceware dot org
  2023-08-03 17:44 ` jbrejon at gmail dot com
  5 siblings, 0 replies; 6+ messages in thread
From: tromey at sourceware dot org @ 2023-08-03 16:06 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |tromey at sourceware dot org
         Resolution|---                         |INVALID

--- Comment #5 from Tom Tromey <tromey at sourceware dot org> ---
The program here is invalid, as Hannes pointed out.
Now, that's exactly when you'd want to use gdb.
However, in this case, gdb ignores the declaration in test.c
in favor of the definition of the object.
IOW, it is doing the right thing.
Expecting it to mimic the undefined behavior of the source
seems a bit weird.

Anyway I don't think we should try to change gdb to do this.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug gdb/24318] GDB prints the wrong value
       [not found] <bug-24318-4717@http.sourceware.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2023-08-03 16:06 ` tromey at sourceware dot org
@ 2023-08-03 17:44 ` jbrejon at gmail dot com
  5 siblings, 0 replies; 6+ messages in thread
From: jbrejon at gmail dot com @ 2023-08-03 17:44 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from e <jbrejon at gmail dot com> ---
(In reply to Tom Tromey from comment #5)
> The program here is invalid, as Hannes pointed out.
it is.


> However, in this case, gdb ignores the declaration in test.c
> in favor of the definition of the object.
> IOW, it is doing the right thing.
Not sure what you mean by that as GDB doesn't prints the same thing in the two
execution. I don't think it favor anything as its not consistent.
Again:
GDB first instance:
...
test () at test.c:8
8               printf("tab[0] == %"PRIx64"\n", tab[0]);
(gdb) p tab[0] <--------------------------------------------(b)
...
GDB second instance:
...
test () at test.c:8
8               printf("tab[0] == %"PRIx64"\n", tab[0]);
(gdb) p/x tab[0] <-------------------------------------------(b)
...

What changed? In the first instance we printed (a) first. It looks like some
kind of type caching. I'm not sure if its intended but that was definitly not
what I expected.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-03 17:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-24318-4717@http.sourceware.org/bugzilla/>
2020-04-07 19:05 ` [Bug gdb/24318] GDB prints the wrong value ssbssa at sourceware dot org
2020-04-07 20:29 ` jbrejon at gmail dot com
2020-04-07 20:38 ` ssbssa at sourceware dot org
2020-04-07 21:40 ` jbrejon at gmail dot com
2023-08-03 16:06 ` tromey at sourceware dot org
2023-08-03 17:44 ` jbrejon at gmail dot com

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).