about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--absl/numeric/int128.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/absl/numeric/int128.h b/absl/numeric/int128.h
index 2eded2f3b549..803f0ff23ab8 100644
--- a/absl/numeric/int128.h
+++ b/absl/numeric/int128.h
@@ -45,8 +45,8 @@ namespace absl {
 // as closely as is practical, including exhibiting undefined behavior in
 // analogous cases (e.g. division by zero). This type is intended to be a
 // drop-in replacement once C++ supports an intrinsic `uint128_t` type; when
-// that occurs, existing uses of `uint128` will continue to work using that new
-// type.
+// that occurs, existing well-behaved uses of `uint128` will continue to work
+// using that new type.
 //
 // Note: code written with this type will continue to compile once `uint128_t`
 // is introduced, provided the replacement helper functions
@@ -70,6 +70,9 @@ namespace absl {
 //     types.
 //   * Conversion to integral types requires an explicit static_cast() to
 //     mimic use of the `-Wnarrowing` compiler flag.
+//   * The alignment requirement of `uint128` may differ from that of an
+//     intrinsic 128-bit integer type depending on platform and build
+//     configuration.
 //
 // Example:
 //
@@ -80,7 +83,11 @@ namespace absl {
 //     absl::uint64_t i = v;                         // Error
 //     absl::uint64_t i = static_cast<uint64_t>(v);  // OK
 //
-class alignas(16) uint128 {
+class
+#if defined(ABSL_HAVE_INTRINSIC_INT128)
+    alignas(unsigned __int128)
+#endif  // ABSL_HAVE_INTRINSIC_INT128
+        uint128 {
  public:
   uint128() = default;