This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/39545] structures with zero-length array passed/returned inconsistently
- From: "hjl dot tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Mar 2009 18:43:07 -0000
- Subject: [Bug target/39545] structures with zero-length array passed/returned inconsistently
- References: <bug-39545-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from hjl dot tools at gmail dot com 2009-03-24 18:43 -------
i386.c has
static int
classify_argument (enum machine_mode mode, const_tree type,
enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset)
{
HOST_WIDE_INT bytes =
(mode == BLKmode) ? int_size_in_bytes (type) : (int) GET_MODE_SIZE (mode);
int words = (bytes + (bit_offset % 64) / 8 + UNITS_PER_WORD - 1) /
UNITS_PER_WORD;
/* Variable sized entities are always passed/returned in memory. */
if (bytes < 0)
return 0;
bytes == 0 for "char xxx[0]" and bytes == -1 for "char xxx[]". We can't
return "char []" and "char xxx[]" is passed as pointer. So
/* Variable sized entities are always passed/returned in memory. */
if (bytes < 0)
return 0;
only applies to zero-length array in a structure like
struct line {
int length;
char contents[];
};
This patch was added by
http://gcc.gnu.org/ml/gcc-patches/2002-08/msg01595.html
Jan, what was the rational for this change?
--
hjl dot tools at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jh at suse dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39545