[LLVMbugs] [Bug 16537] New: ABI issue with the C++11 definition of POD and tail padding

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jul 3 19:23:07 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16537

            Bug ID: 16537
           Summary: ABI issue with the C++11 definition of POD and tail
                    padding
           Product: clang
           Version: 3.2
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: joshua_magee at playstation.sony.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 10817
  --> http://llvm.org/bugs/attachment.cgi?id=10817&action=edit
Reproducable test case

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130704/c133fd58/attachment.html>


More information about the llvm-bugs mailing list