[Bug c/30160] New: enum reporting sizeof == 0

2006-12-11 Thread richard at beatnik dot com
Hello,

I'm compiling on cygwin on my Dell Laptop.  I'm running windows xp pro, with
the 3.4.4 version of gcc

my source file:
#include 

typedef enum {
ac = -1,
ab = 0x,
aa = 1,
} en;

int main()
{
en  a = ab;
printf("a = %d sizeof %d\n", a, sizeof(en));
return 0;
}

$ gcc -Wall test.c
test.c: In function `main':
test.c:11: warning: int format, different type arg (arg 2)


$ ./a.exe
a = -1 sizeof 0


shouldn't sizeof be 4?


-- 
   Summary: enum reporting sizeof == 0
   Product: gcc
   Version: 3.4.4
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: richard at beatnik dot com
 GCC build triplet: 3.4.4
  GCC host triplet: 3.4.4
GCC target triplet: 3.4.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30160



[Bug c/30160] enum reporting sizeof == 0

2006-12-11 Thread richard at beatnik dot com


--- Comment #1 from richard at beatnik dot com  2006-12-12 00:51 ---
Created an attachment (id=12787)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12787&action=view)
test file for creating bug


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30160



[Bug c/30160] enum reporting sizeof == 0

2006-12-11 Thread richard at beatnik dot com


--- Comment #3 from richard at beatnik dot com  2006-12-12 01:29 ---
Ahh,

I see.

Because the a is supposed to be long long, that means that it is of size 8,
which would mean that it takes two regs (or stack spaces, or where ever gcc
stores it's arguments).  Then the second %d in the string gets the second of
the two args, thus being zero:
 -
 V   | first half of the 8 byte argument
printf( "a = %d sizeof %d\n", a, sizeof(en));
   ^ | second half of the 8 byte argument
   ---

When I change to 

 -
 V   | the 8 byte argument
printf( "a = %lld sizeof %d\n", a, sizeof(en));
   ^| 
   --

Thanks


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30160