[PATCH] D119051: Extend the C++03 definition of POD to include defaulted functions

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 11 16:39:29 PDT 2022


dblaikie added a comment.

> So I could test this other ways that actually impact layout - like whether things can be packed in tail padding (can pack in tail padding for non-pod, right?). Or we could ast dump and inspect the property directly? Maybe there are some other options?

Here's what the tail-padding based testing looks like: https://godbolt.org/z/Te3d4fYjj (though the asserts all fail on MSVC... not sure what size MSVC makes these structs at all)

  namespace trailing {
  struct t1 {
      int x;
      char c;
  };
  struct t2 : t1 {
      char c;  
  };
  static_assert(sizeof(t2) == sizeof(int) * 3, "");
  } // namespace trailing
  namespace trailing_nonpod {
  struct t1 {
  protected:
      int x;
      char c;
  };
  struct t2 : t1  {
      char c;
  };
  static_assert(sizeof(t2) == sizeof(int) * 2, "");
  }  // namespace trailing_nonpod
  namespace trailing_smf_defaulted_pod {
  struct t1 {
      t1() = default;
      int a;
      char c;
  };
  struct t2 : t1 {
      char c;
  };
  static_assert(sizeof(t2) == sizeof(int) * 3, "");
  }

(GCC passes all these assertions, Clang (without this patch we're reviewing) fails the last of them)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119051/new/

https://reviews.llvm.org/D119051



More information about the cfe-commits mailing list