public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59259] New: [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure
@ 2013-11-23 7:11 cjanderson at yandex dot com
2013-11-23 7:12 ` [Bug c/59259] " cjanderson at yandex dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: cjanderson at yandex dot com @ 2013-11-23 7:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59259
Bug ID: 59259
Summary: [x32] Incorrect packing and/or alignment when using a
64 bit type as array of zero length in a structure
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: cjanderson at yandex dot com
I believe that x32 has 32 bit pointers. I hope that I am not barking up the
wrong tree, but I have a problem with gcc versions 4.7.2 4.8.3 and the current
head on git with the following:
struct blah {
long long a,b;
};
struct ipt_get_entries {
unsigned int size;
struct blah entrytable[0];
};
int x = sizeof(struct ipt_get_entries);
which produces the following when compiled with the -mx32 flag. ie. cc1 -mx32
produces:
.file "1.c"
.globl x
.data
.align 4
.type x, @object
.size x, 4
x:
.long 8
.ident "GCC: (GNU) 4.9.0 20131120 (experimental)"
.section .note.GNU-stack,"",@progbits
When compiled with the -m32 flag the size is 4 and with the -m64 flag the size
is 8.
However, if you change the blah struct to a 32 bit value, ie
struct blah {
long long a,b;
};
...
The result for x is 4.
Also, when using -fpack-struct=4 the value of 4 is given, for all of -mx32 -m32
and -m64.
The behaviour here seems to be that x32 is doing the same as for 64 bit. Is
this correct.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59259] [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure
2013-11-23 7:11 [Bug c/59259] New: [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure cjanderson at yandex dot com
@ 2013-11-23 7:12 ` cjanderson at yandex dot com
2013-11-23 7:44 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: cjanderson at yandex dot com @ 2013-11-23 7:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59259
--- Comment #1 from cjanderson at yandex dot com ---
Created attachment 31276
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31276&action=edit
Test file incorrectly compiled
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59259] [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure
2013-11-23 7:11 [Bug c/59259] New: [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure cjanderson at yandex dot com
2013-11-23 7:12 ` [Bug c/59259] " cjanderson at yandex dot com
@ 2013-11-23 7:44 ` pinskia at gcc dot gnu.org
2013-11-23 10:24 ` cjanderson at yandex dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-11-23 7:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59259
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The alignment of ipt_get_entries for x32 is 64bit so the size is correct. This
is different from x86 where the alignment of long long in struct is 32bits.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59259] [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure
2013-11-23 7:11 [Bug c/59259] New: [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure cjanderson at yandex dot com
2013-11-23 7:12 ` [Bug c/59259] " cjanderson at yandex dot com
2013-11-23 7:44 ` pinskia at gcc dot gnu.org
@ 2013-11-23 10:24 ` cjanderson at yandex dot com
2013-11-27 11:42 ` cjanderson at yandex dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: cjanderson at yandex dot com @ 2013-11-23 10:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59259
cjanderson at yandex dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |CLOSED
--- Comment #3 from cjanderson at yandex dot com ---
Thanks.
> The alignment of ipt_get_entries for x32 is 64bit so the size is correct.
> This is different from x86 where the alignment of long long in struct is
> 32bits.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59259] [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure
2013-11-23 7:11 [Bug c/59259] New: [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure cjanderson at yandex dot com
` (2 preceding siblings ...)
2013-11-23 10:24 ` cjanderson at yandex dot com
@ 2013-11-27 11:42 ` cjanderson at yandex dot com
2013-11-27 12:00 ` schwab@linux-m68k.org
2013-11-27 12:20 ` cjanderson at yandex dot com
5 siblings, 0 replies; 7+ messages in thread
From: cjanderson at yandex dot com @ 2013-11-27 11:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59259
cjanderson at yandex dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|CLOSED |UNCONFIRMED
Resolution|INVALID |---
--- Comment #4 from cjanderson at yandex dot com ---
Sorry, this still troubles me. Isn't the last structure a pointer, ie:
struct blah entrytable[0];
is really just a pointer, and hence in most cases just an 32 bit value (I know
there are some tricks), but if it is a pointer then the alignment should surely
be the same as for ia32?
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59259] [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure
2013-11-23 7:11 [Bug c/59259] New: [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure cjanderson at yandex dot com
` (3 preceding siblings ...)
2013-11-27 11:42 ` cjanderson at yandex dot com
@ 2013-11-27 12:00 ` schwab@linux-m68k.org
2013-11-27 12:20 ` cjanderson at yandex dot com
5 siblings, 0 replies; 7+ messages in thread
From: schwab@linux-m68k.org @ 2013-11-27 12:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59259
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #5 from Andreas Schwab <schwab@linux-m68k.org> ---
A flexible array member is not a pointer.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/59259] [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure
2013-11-23 7:11 [Bug c/59259] New: [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure cjanderson at yandex dot com
` (4 preceding siblings ...)
2013-11-27 12:00 ` schwab@linux-m68k.org
@ 2013-11-27 12:20 ` cjanderson at yandex dot com
5 siblings, 0 replies; 7+ messages in thread
From: cjanderson at yandex dot com @ 2013-11-27 12:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59259
cjanderson at yandex dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |CLOSED
--- Comment #6 from cjanderson at yandex dot com ---
ok
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-11-27 12:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-23 7:11 [Bug c/59259] New: [x32] Incorrect packing and/or alignment when using a 64 bit type as array of zero length in a structure cjanderson at yandex dot com
2013-11-23 7:12 ` [Bug c/59259] " cjanderson at yandex dot com
2013-11-23 7:44 ` pinskia at gcc dot gnu.org
2013-11-23 10:24 ` cjanderson at yandex dot com
2013-11-27 11:42 ` cjanderson at yandex dot com
2013-11-27 12:00 ` schwab@linux-m68k.org
2013-11-27 12:20 ` cjanderson at yandex 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).