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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|va_start corrupts 6-th      |empty struct value is
                   |argument in case of empty   |passed differently in C and
                   |type used before the format |C++
                   |string                      |

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Andrew Pinski from comment #3)
> (In reply to H.J. Lu from comment #2)
> > Should g++ put pass the empty struct on stack?
> 
> It is a target bug if it is passing on the stack.  Note in C++, the size of
> the struct is 1 while in C, the size is 0.

Can someone try this on non-x86 targets?

[hjl@gnu-6 pr60336]$ cat x.ii 
struct dummy { };
struct foo
{
  int i1;
  int i2;
  int i3;
  int i4;
  int i5;
};

extern "C" void fun(struct dummy, struct foo);

int main()
{
  struct dummy d;
  struct foo f = { -1, -2, -3, -4, -5 };

  fun(d, f);
  return 0;
}
[hjl@gnu-6 pr60336]$ cat fun.i 
struct dummy { };
struct foo
{
  int i1;
  int i2;
  int i3;
  int i4;
  int i5;
};

void fun(struct dummy d, struct foo f)
{
  if (f.i1 != -1)
    __builtin_abort();
}
[hjl@gnu-6 pr60336]$ gcc -c fun.i 
[hjl@gnu-6 pr60336]$ gcc -c x.ii
[hjl@gnu-6 pr60336]$ g++ fun.o x.o
[hjl@gnu-6 pr60336]$ ./a.out 
Aborted
[hjl@gnu-6 pr60336]$ 

Is this test valid? BTW, clang works fine on x86.

Reply via email to