Bug 11530 - sizeof of anonymous union member does not work
Summary: sizeof of anonymous union member does not work
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: exp (show other bugs)
Version: unknown
: P2 normal
Target Milestone: 7.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-23 10:00 UTC by Jan Kratochvil
Modified: 2010-10-11 22:04 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2010-04-23 10:00:23 UTC
struct a
  {
    union
      {
        int i;
      };
  } a;
int
main (void)
{
  return sizeof (a.i);
}
-------------------------------------------------------------------------------
C code returns 4.
GDB:
(gdb) p sizeof (a.i)
Type struct a has no component named i.
Although:
(gdb) p a.i
$1 = 0
Comment 1 Sourceware Commits 2010-05-11 22:03:20 UTC
Subject: Bug 11530

CVSROOT:	/cvs/src
Module name:	src
Changes by:	muller@sourceware.org	2010-05-11 22:03:04

Modified files:
	gdb            : gdbtypes.c ChangeLog 
	gdb/testsuite  : ChangeLog 
Added files:
	gdb/testsuite/gdb.base: gdb11530.c gdb11530.exp 

Log message:
	2010-05-11  Pierre Muller  <muller@ics.u-strasbg.fr>
	
	PR exp/11530.
	* gdbtypes.c (lookup_struct_elt_type): Also lookup
	names of unnamed structures or unions.
	
	testsuite ChangeLog entry:
	
	2010-05-11  Pierre Muller  <muller@ics.u-strasbg.fr>
	
	PR exp/11530.
	* testsuite/gdb.base/gdb11530.c: New file.
	* testsuite/gdb.base/gdb11530.exp: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/gdbtypes.c.diff?cvsroot=src&r1=1.190&r2=1.191
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11778&r2=1.11779
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2264&r2=1.2265
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/gdb11530.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/gdb11530.exp.diff?cvsroot=src&r1=NONE&r2=1.1

Comment 2 Tom Tromey 2010-10-11 22:04:51 UTC
I think this was fixed.