This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Should structure with flexible array be allowed to be passed by value?
On Tue, Mar 24, 2009 at 8:16 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Tue, 24 Mar 2009, H.J. Lu wrote:
>
>> Should
>>
>> struct line {
>> ? ? ? ?int length;
>> ? ? ? ?char contents[0];
>> ?};
>>
>> or
>>
>> struct line {
>> ? ? ? ?int length;
>> ? ? ? ?char contents[];
>> ?};
>>
>> be allowed to be passed by value? If yes, how do you access the contents field?
>
> I see nothing about passing by value different from structure assignment,
> which ignores the flexible array member (see 6.7.2.1 paragraph 22 (in
> N1256) for an example stating this). ?Although argument passing and return
> aren't strictly assignments, they generally act in the same way, so such a
> structure passed by value or used as a function return value loses the
> flexible array members in the process. ?I suppose an optional warning for
> this might be useful.
>
How should be they passed on x86-64? psABI isn't clear and gcc isn't consistent
with char contents[0] vs char contents[].
--
H.J.