public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/60336] empty struct value is passed differently in C and C++
Date: Wed, 26 Feb 2014 17:03:00 -0000	[thread overview]
Message-ID: <bug-60336-4-qcaoDqF531@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60336-4@http.gcc.gnu.org/bugzilla/>

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.


  parent reply	other threads:[~2014-02-26 17:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-25  9:36 [Bug other/60336] New: va_start corrupts 6-th argument in case of empty type used before the format string ahanins at gmail dot com
2014-02-25 19:53 ` [Bug other/60336] " mikpelinux at gmail dot com
2014-02-25 21:41 ` [Bug c++/60336] " hjl.tools at gmail dot com
2014-02-25 22:35 ` [Bug target/60336] " pinskia at gcc dot gnu.org
2014-02-26 17:03 ` hjl.tools at gmail dot com [this message]
2014-02-26 18:09 ` [Bug target/60336] empty struct value is passed differently in C and C++ ubizjak at gmail dot com
2014-02-26 19:06 ` hjl.tools at gmail dot com
2014-02-26 19:25 ` vagran.ast at gmail dot com
2014-02-26 19:31 ` pinskia at gcc dot gnu.org
2014-02-26 19:32 ` hjl.tools at gmail dot com
2014-02-26 19:51 ` glisse at gcc dot gnu.org
2014-02-26 19:55 ` hjl.tools at gmail dot com
2014-02-27 14:37 ` jason at gcc dot gnu.org
2014-02-27 16:04 ` hjl.tools at gmail dot com
2014-02-27 16:17 ` ubizjak at gmail dot com
2014-02-27 17:58 ` jason at gcc dot gnu.org
2014-02-27 18:41 ` jason at gcc dot gnu.org
2014-02-27 20:53 ` ubizjak at gmail dot com
2014-02-27 21:21 ` pinskia at gcc dot gnu.org
2014-08-12 19:21 ` [Bug c++/60336] " hjl.tools at gmail dot com
2014-08-12 22:58 ` pinskia at gcc dot gnu.org
2014-08-13  5:05 ` vagran.ast at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60336-4-qcaoDqF531@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).