Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABI issue with the C++11 definition of POD and tail padding #16911

Closed
llvmbot opened this issue Jul 4, 2013 · 2 comments
Closed

ABI issue with the C++11 definition of POD and tail padding #16911

llvmbot opened this issue Jul 4, 2013 · 2 comments
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category

Comments

@llvmbot
Copy link
Member

llvmbot commented Jul 4, 2013

Bugzilla Link 16537
Resolution FIXED
Resolved on Jul 19, 2013 20:49
Version 3.2
OS Linux
Attachments Reproducable test case, Sample / incomplete patch
Reporter LLVM Bugzilla Contributor
CC @gribozavr,@rengolin

Extended Description

The attached testcase will or will not use tail padding depending on the
language mode (C++03 versus C++11). The test uses a class that is POD in C++11
but non-POD in C++03. Using a recent TOT of compiler (clang r185419), the
compiler will use the tail padding in C++03 mode but will not use it in C++11
mode.

The Itanium C++ ABI (http://mentorembedded.github.io/cxx-abi/abi.html) has a
clause which states that for the purpose of layout the C++03 definition of POD
should be used:

" POD for the purpose of layout

...

There have been multiple published revisions to the ISO C++ standard,
and each one has included a different definition of POD. To ensure
interoperation of code compiled according to different revisions of
the standard, it is necessary to settle on a single definition for a
platform. A platform vendor may choose to follow a different revision
of the standard, but by default, the definition of POD under this ABI
is the definition from the 2003 revision (TC1).
"

Furthermore, r173744 refactored the RecordLayoutBuilder code and added comments
which suggest that Clang should be following the Itanium ABI with respect
towards the above POD layout rules:
"
// To preserve binary compatibility, the generic Itanium ABI has
// permanently locked the definition of POD to the rules of C++ TR1,
// and that trickles down to all the derived ABIs.
"

Given this, I would expect the attached testcase to use the tail padding even
in C++11 mode. It seems that code responsible for determining if tail padding
should be used (mustSkipTailPadding) expects that isPOD() checks the C++ TR1
(2003) definition of POD, however the behaviour with this testcase shows that
isPOD is not using the TR1 definition in all cases.

This problem showed up in Clang 3.2 (Clang 3.1 worked correctly). The
specific revision that introduces the problem was r155756 which made isPODType
decide which POD rules (C++98 or C++11) rules to use depending on the
LangOptions.
The result is that this bug introduced ABI incompatibility between 3.1 and 3.2
when using C++11.

@llvmbot
Copy link
Member Author

llvmbot commented Jul 4, 2013

See also Bug 13329 where clang's handling of tail padding of non-PODs was changed (between 3.1 and 3.2).

@llvmbot
Copy link
Member Author

llvmbot commented Jul 20, 2013

Fixed in r186741.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang Clang issues not falling into any other category
Projects
None yet
Development

No branches or pull requests

1 participant