public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52792] New: this pointer and return pointer are passed in wrong order when ms_abi is used (x86_64)
@ 2012-03-30 15:38 piotr at codeweavers dot com
  2012-10-05 19:36 ` [Bug c++/52792] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: piotr at codeweavers dot com @ 2012-03-30 15:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52792

             Bug #: 52792
           Summary: this pointer and return pointer are passed in wrong
                    order when ms_abi is used (x86_64)
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: piotr@codeweavers.com


Created attachment 27045
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27045
program that demonstrates the problem

When class function returns structure this pointer should be passed as first
argument. Pointer to memory used by returned value should be passed as second
argument. Currently gcc swaps these to parameters.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/52792] this pointer and return pointer are passed in wrong order when ms_abi is used (x86_64)
  2012-03-30 15:38 [Bug c++/52792] New: this pointer and return pointer are passed in wrong order when ms_abi is used (x86_64) piotr at codeweavers dot com
@ 2012-10-05 19:36 ` paolo.carlini at oracle dot com
  2012-12-05 12:52 ` paolo.carlini at oracle dot com
  2020-11-21  3:53 ` p_hampson at wargaming dot net
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-05 19:36 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52792

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cgf at gcc dot gnu.org,
                   |                            |ktietz at gcc dot gnu.org

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-05 19:36:33 UTC ---
Not sure if the Christopher and Kai spend time also on the C++ front-end bits,
but CC-ing them anyway.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/52792] this pointer and return pointer are passed in wrong order when ms_abi is used (x86_64)
  2012-03-30 15:38 [Bug c++/52792] New: this pointer and return pointer are passed in wrong order when ms_abi is used (x86_64) piotr at codeweavers dot com
  2012-10-05 19:36 ` [Bug c++/52792] " paolo.carlini at oracle dot com
@ 2012-12-05 12:52 ` paolo.carlini at oracle dot com
  2020-11-21  3:53 ` p_hampson at wargaming dot net
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-12-05 12:52 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52792

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-12-05 12:52:00 UTC ---
Likewise, Kai, please.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/52792] this pointer and return pointer are passed in wrong order when ms_abi is used (x86_64)
  2012-03-30 15:38 [Bug c++/52792] New: this pointer and return pointer are passed in wrong order when ms_abi is used (x86_64) piotr at codeweavers dot com
  2012-10-05 19:36 ` [Bug c++/52792] " paolo.carlini at oracle dot com
  2012-12-05 12:52 ` paolo.carlini at oracle dot com
@ 2020-11-21  3:53 ` p_hampson at wargaming dot net
  2 siblings, 0 replies; 4+ messages in thread
From: p_hampson at wargaming dot net @ 2020-11-21  3:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52792

Paul "TBBle" Hampson <p_hampson at wargaming dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |p_hampson at wargaming dot net

--- Comment #6 from Paul "TBBle" Hampson <p_hampson at wargaming dot net> ---
Since this came up on Stack Overflow, I thought I'd note the outcomes here.

https://stackoverflow.com/a/62880979/166389

The original report is accurate, as the ordering of "first argument hidden
this" and "first argument return-value pointer" differs in gcc compared to msvc
and clang.

It's ambiguous in the MSVC ABI documentation as the two behaviours are
specified in different document sets and both claim to become "the first
argument". I have raised an issue with Microsoft about this:
https://github.com/MicrosoftDocs/windows-driver-docs/issues/2586

There's also another related C++ issue (the actual SO question that triggered
my investigation) as gcc will return a user-defined type (struct) by value in
RAX for power-of-two-sized C++03 POD types, but the the MSVC ABI documentation
(and observed behaviour in msvc and clang) specify that
return-struct-in-register is only supported
> from global functions and static member functions.

https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention#return-values

None of the examples here trigger this bug, as they all use sufficiently-large
aggregates that they would not be candidates for return-struct-in-register
anyway.

I was only looking at the x64 documentation, but minimal testing bears out the
same results for 32-bit MSVC C++ ABI.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-21  3:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-30 15:38 [Bug c++/52792] New: this pointer and return pointer are passed in wrong order when ms_abi is used (x86_64) piotr at codeweavers dot com
2012-10-05 19:36 ` [Bug c++/52792] " paolo.carlini at oracle dot com
2012-12-05 12:52 ` paolo.carlini at oracle dot com
2020-11-21  3:53 ` p_hampson at wargaming dot net

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).