This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Cc: GCC Development <gcc at gcc dot gnu dot org>, cfe-commits <cfe-commits at lists dot llvm dot org>
- Date: Sun, 7 Feb 2016 12:40:11 -0800
- Subject: Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOofYT89yzF6jxFZFG2=QVQuQpEC7DP0HV_epjeawCf_sA at mail dot gmail dot com> <87d1s8wc4w dot fsf at mid dot deneb dot enyo dot de> <CAMe9rOp_6ZpR1YSJZ7AiLpa+FPRGJoLm5fTPkiH5BgF4Tkg3RA at mail dot gmail dot com> <87r3gouvv2 dot fsf at mid dot deneb dot enyo dot de>
On Sun, Feb 7, 2016 at 12:08 PM, Florian Weimer <fw@deneb.enyo.de> wrote:
> * H. J. Lu:
>
>>> Any syntactical array argument (at the C level) is should be passed as
>>> a pointer. The language appears to change that.
>>
>> I didn't use aggregate so that array is excluded here.
>>
>>> For 2., static members and non-data members do not count.
>>
>> They do count here. That is why I used "POD for the purpose of
>> layout.
>
> Let's see what happens today.
>
> struct s0 {
> s0();
> };
>
> struct s1 {
> static int a;
> };
>
> struct s2 {
> void member();
> };
>
> struct s3 {
> int a[0];
> };
>
> struct s4 {
> s0 a[0];
> };
>
> struct s5 {
> s1 a[1];
> };
>
>
> I tested GCC 5.3.1 and Clang 3.5.0.
>
> GCC Clang
> s0 non-empty non-empty
> s1 non-empty empty
> s2 non-empty empty
> s3 empty empty
> s4 empty empty
> s5 non-empty empty
>
> I believe s3, s4, s5 are non-empty according to your rules. Why put
> both compilers in the wrong? That doesn't make sense to me.
Please try testcases in
https://llvm.org/bugs/show_bug.cgi?id=26337
with clang on both ia32 and x86-64. Clang isn't consistent between
ia32 and x86-64.
> Jason already indicated he intends GCC to move towards more empty
> arguments, not fewer.
>
>>> How do existing C++ compilers implement empty array members (an
>>> extension)? Does the type of such members affect whether a class is a
>>> standard-layout class?
>
>> Are they "POD for the purpose of layout"? If yes, they are covered here.
>
> The C++ standard does not define this.
GCC has
* Nonzero means that this class type is not POD for the purpose of layout
(as defined in the ABI). This is different from the language's POD. */
#define CLASSTYPE_NON_LAYOUT_POD_P(NODE) \
We can use this definition for ia32, x86-64 and IA MCU psABIs.
--
H.J.