This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Should structure with flexible array be allowed to be passed by value?


On Tue, 24 Mar 2009, Gabriel Dos Reis wrote:

> > 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.
> 
> This strikes me as dangerous and mostly useless.  I would have
> expected an error.

I've now raised the question on the WG14 list, but I'd expect consistency 
with assignment.

Another case that should be covered in compat testcases is passing such a 
structure to a variadic function and retrieving it with va_arg; again, 
this would ignore the flexible array member.

-- 
Joseph S. Myers
joseph@codesourcery.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]