From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: "H.J. Lu" <hjl.tools@gmail.com>, Jason Merrill <jason@redhat.com>,
Richard Biener <richard.guenther@gmail.com>,
Markus Trippelsdorf <markus@trippelsdorf.de>
Subject: Re: PING^1: [PATCH] Add TYPE_EMPTY_RECORD for C++ empty class
Date: Wed, 27 Jan 2016 08:21:00 -0000 [thread overview]
Message-ID: <20160127082107.GN3017@tucnak.redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1601270858440.1966@laptop-mg.saclay.inria.fr>
On Wed, Jan 27, 2016 at 09:10:14AM +0100, Marc Glisse wrote:
> >Revised:
> >
> >/* Returns true if TYPE is POD of one-byte or less in size for the purpose
> > of layout and an empty class or an class with empty classes. */
> >
> >static bool
> >is_empty_record (tree type)
> >{
> > if (type == error_mark_node)
> > return false;
> >
> > if (!CLASS_TYPE_P (type))
> > return false;
> >
> > if (CLASSTYPE_NON_LAYOUT_POD_P (type))
> > return false;
> >
> > gcc_assert (COMPLETE_TYPE_P (type));
> >
> > if (CLASSTYPE_EMPTY_P (type))
> > return true;
> >
> > if (int_size_in_bytes (type) > 1)
> > return false;
>
> That's completely arbitrary :-(
Yeah. Because (adapted to be compilable with C):
struct A1 {}; struct A2 {};
struct B1 { struct A1 a; struct A2 b; }; struct B2 { struct A1 a; struct A2 b; };
struct C1 { struct B1 a; struct B2 b; }; struct C2 { struct B1 a; struct B2 b; };
struct D1 { struct C1 a; struct C2 b; }; struct D2 { struct C1 a; struct C2 b; };
struct E1 { struct D1 a; struct D2 b; }; struct E2 { struct D1 a; struct D2 b; };
struct F1 { struct E1 a; struct E2 b; }; struct F2 { struct E1 a; struct E2 b; };
struct G1 { struct F1 a; struct F2 b; }; struct G2 { struct F1 a; struct F2 b; };
struct H1 { struct G1 a; struct G2 b; }; struct H2 { struct G1 a; struct G2 b; };
struct I1 { struct H1 a; struct H2 b; }; struct I2 { struct H1 a; struct H2 b; };
struct J1 { struct I1 a; struct I2 b; }; struct J2 { struct I1 a; struct I2 b; };
struct K1 { struct J1 a; struct J2 b; };
int v;
__attribute__((noinline, noclone))
struct K1 foo (int a, struct K1 x, int b)
{
v = a + b;
return x;
}
struct K1 k, m;
void
bar (void)
{
m = foo (1, k, 2);
}
then would have a different calling convention between C and C++,
so where is the argument that we change anything just to make the two
compatible? Though, of course, those two will never be compatible,
it is enough to add struct L1 { int a; struct K1 b; int c; }; and
that structure has 1024+8 bytes in C++ and 8 bytes in C.
As clang generates different code for the above between C and C++, it
clearly special cases for some reason just the most common case.
IMHO it is not worth to change GCC ABI...
Jakub
next prev parent reply other threads:[~2016-01-27 8:21 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-08 16:22 H.J. Lu
2015-12-09 14:05 ` Richard Biener
2015-12-09 18:53 ` H.J. Lu
2015-12-09 21:14 ` H.J. Lu
2015-12-09 21:31 ` Markus Trippelsdorf
2015-12-10 11:24 ` Richard Biener
2015-12-11 23:52 ` H.J. Lu
2015-12-12 14:51 ` Jason Merrill
2015-12-12 15:27 ` Jakub Jelinek
2015-12-12 16:45 ` H.J. Lu
2015-12-12 18:43 ` Marc Glisse
2015-12-14 20:16 ` Jason Merrill
2015-12-14 20:39 ` H.J. Lu
2015-12-14 20:44 ` Jason Merrill
2015-12-14 22:08 ` H.J. Lu
2016-01-26 19:27 ` Jason Merrill
2016-01-26 19:52 ` H.J. Lu
2016-01-26 20:23 ` Marc Glisse
2016-01-26 20:26 ` H.J. Lu
2016-01-26 20:44 ` Marc Glisse
2016-01-26 21:21 ` H.J. Lu
2016-01-26 21:40 ` Jakub Jelinek
2016-01-26 22:21 ` H.J. Lu
2016-01-27 8:10 ` Marc Glisse
2016-01-27 8:21 ` Jakub Jelinek [this message]
2016-01-27 9:03 ` Marc Glisse
2016-01-27 13:46 ` H.J. Lu
2016-01-27 15:39 ` H.J. Lu
2016-03-01 1:02 ` Jason Merrill
2016-03-01 22:44 ` H.J. Lu
2016-03-02 16:25 ` Ulrich Weigand
2016-03-02 17:34 ` H.J. Lu
2016-03-15 15:35 ` Jason Merrill
2016-03-15 16:00 ` H.J. Lu
2016-03-15 19:32 ` Jason Merrill
2016-03-16 12:38 ` H.J. Lu
2016-03-16 16:58 ` Jason Merrill
2016-03-16 17:02 ` H.J. Lu
2016-03-16 19:39 ` H.J. Lu
2016-03-16 19:43 ` Jason Merrill
2016-03-15 21:40 ` Joseph Myers
2016-03-15 22:31 ` H.J. Lu
2016-03-15 22:35 ` Joseph Myers
2016-03-16 0:23 ` H.J. Lu
2016-03-16 0:25 ` Joseph Myers
2016-03-16 2:17 ` H.J. Lu
2016-03-16 9:46 ` Bernhard Reutner-Fischer
2016-03-16 11:53 ` H.J. Lu
2016-03-16 2:51 ` Jason Merrill
2016-03-16 11:55 ` H.J. Lu
2016-03-16 14:33 ` Jason Merrill
2016-03-16 14:48 ` H.J. Lu
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=20160127082107.GN3017@tucnak.redhat.com \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@gmail.com \
--cc=jason@redhat.com \
--cc=markus@trippelsdorf.de \
--cc=richard.guenther@gmail.com \
/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).