This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Gcc 3.0 and unnamed struct: incorrect offsets


Hello folks,
	This might have already been addressed, but I
tried searching on GCC mailing list archives
http://gcc.gnu.org/lists.html#searchbox
and google before posting.

My test file:
			--------
$ cat gcc_prob.c
struct a {
    struct {
        struct {
            int x, y;
        };
        struct {
            int z;
        };
    };
}dummy;

int main(void)
{
    dummy.x = 20;
    dummy.z = 10;
}
			--------

My GCC version (cross-compiled to generate MIPS code):
bash-2.05b$ mips-elf-gcc --version
3.0

Disassembly of code:

bash-2.05b$ objdump  -D gcc_prob.o

			---------
00000000 <main>:
   0:   27bdffe8        addiu   sp,sp,-24
   4:   afbf0014        sw      ra,20(sp)
   8:   afbe0010        sw      s8,16(sp)
   c:   0c000000        jal     0 <main>
  10:   03a0f021        move    s8,sp
  14:   24020014        addiu   v0,zero,20
  18:   3c010000        lui     at,0x0
  1c:   ac220000        sw      v0,0(at)
  20:   2402000a        addiu   v0,zero,10
  24:   3c010000        lui     at,0x0
  28:   ac220000        sw      v0,0(at)
  2c:   03c0e821        move    sp,s8
  30:   8fbf0014        lw      ra,20(sp)
  34:   8fbe0010        lw      s8,16(sp)
  38:   03e00008        jr      ra
  3c:   27bd0018        addiu   sp,sp,24

			---------
Instructions at locations 0x14 - 0x1c correspond to:
    dummy.x = 20;

And, instructions at locations 0x20 - 0x28 correspond to:
    dummy.z = 10;

Puzzling part is both stores happen at offset of '0':
  1c:   ac220000        sw      v0,0(at)
		... ... ...
  28:   ac220000        sw      v0,0(at)

I wanted to know if this is a bug, and if yes, then probably
I might hunt for a patch. If not, then can you please point
what's wrong? Or explain this not-so-obvious behaviour?
Is it something specific to MIPS arch?

BTW, with x86 GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
I do see correct offsets!

TIA.

Regards,
Atul T
http://the-shaolin.blogspot.com/
----------------------------------------------------------
Computers are like air conditioners---
They stop working properly if you open WINDOWS!
----------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]