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: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct


On 20 February 2016 at 18:55, H.J. Lu <hjl.tools@gmail.com> wrote:
> struct dummy0
> {
> };
>
> struct dummy
> {
>   dummy0 d[20];
>
>   dummy0 * foo (int i);
> };
>
> dummy0 *
> dummy::foo (int i)
> {
>   return &d[i];
> }
>
> dummy0 *
> bar (dummy d, int i)
> {
>   return d.foo (i);
> }

1. This has undefined behaviour due to returning a pointer to a local variable
2. There's still no need for the reference to the original argument
since copying it is a nop.


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