[clang] 711c669 - Fix comment to more accurately describe C++ language requirements around tail padding.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 2 14:41:36 PST 2019


Author: Richard Smith
Date: 2019-12-02T14:41:27-08:00
New Revision: 711c669ae92658aecc6fabccc583594924bac6d7

URL: https://github.com/llvm/llvm-project/commit/711c669ae92658aecc6fabccc583594924bac6d7
DIFF: https://github.com/llvm/llvm-project/commit/711c669ae92658aecc6fabccc583594924bac6d7.diff

LOG: Fix comment to more accurately describe C++ language requirements around tail padding.

Summary:
As of C++ core issue 43 (http://wg21.link/cwg43), which was voted into
the C++ working draft in 1999, it is not permissible to memcpy a base
class subobject, even if it's of POD type, so there is no problem with
reusing the tail padding of a base class. That issue was voted into the
standard in DR status, so it applies retroactively to C++98 (and is in
any case part of C++03).

So stop suggesting that AlwaysUseTailPadding mode is non-conforming.

Reviewers: rjmccall

Reviewed By: rjmccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D70923

Added: 
    

Modified: 
    clang/include/clang/Basic/TargetCXXABI.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/TargetCXXABI.h b/clang/include/clang/Basic/TargetCXXABI.h
index b1be40272513..60343fe99c1d 100644
--- a/clang/include/clang/Basic/TargetCXXABI.h
+++ b/clang/include/clang/Basic/TargetCXXABI.h
@@ -277,27 +277,18 @@ class TargetCXXABI {
   /// padding of a base class?
   ///
   /// This decision cannot be changed without breaking platform ABI
-  /// compatibility, and yet it is tied to language guarantees which
-  /// the committee has so far seen fit to strengthen no less than
-  /// three separate times:
-  ///   - originally, there were no restrictions at all;
-  ///   - C++98 declared that objects could not be allocated in the
-  ///     tail padding of a POD type;
-  ///   - C++03 extended the definition of POD to include classes
-  ///     containing member pointers; and
-  ///   - C++11 greatly broadened the definition of POD to include
-  ///     all trivial standard-layout classes.
-  /// Each of these changes technically took several existing
-  /// platforms and made them permanently non-conformant.
+  /// compatibility. In ISO C++98, tail padding reuse was only permitted for
+  /// non-POD base classes, but that restriction was removed retroactively by
+  /// DR 43, and tail padding reuse is always permitted in all de facto C++
+  /// language modes. However, many platforms use a variant of the old C++98
+  /// rule for compatibility.
   enum TailPaddingUseRules {
     /// The tail-padding of a base class is always theoretically
-    /// available, even if it's POD.  This is not strictly conforming
-    /// in any language mode.
+    /// available, even if it's POD.
     AlwaysUseTailPadding,
 
     /// Only allocate objects in the tail padding of a base class if
     /// the base class is not POD according to the rules of C++ TR1.
-    /// This is non-strictly conforming in C++11 mode.
     UseTailPaddingUnlessPOD03,
 
     /// Only allocate objects in the tail padding of a base class if


        


More information about the cfe-commits mailing list