This is the mail archive of the gcc-bugs@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]

[Bug target/39545] structures with zero-length array passed/returned inconsistently



------- 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


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