From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21465 invoked by alias); 26 Feb 2014 17:03:32 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 21385 invoked by uid 48); 26 Feb 2014 17:03:28 -0000 From: "hjl.tools at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: short_desc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-02/txt/msg02616.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60336 H.J. Lu 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 --- (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.