This is an archive of the discontinued LLVM Phabricator instance.

isPodLike: handle tuple and array
AbandonedPublic

Authored by jfb on Sep 10 2018, 11:37 AM.

Details

Reviewers
None
Summary

Just like isPodLike already handles pair, it should special-case tuple and array. This is really only useful for GCC before 5.0, so hopefully this workaround won't be around for long.

Diff Detail

Event Timeline

jfb created this revision.Sep 10 2018, 11:37 AM
jfb updated this revision to Diff 164732.Sep 10 2018, 12:40 PM
  • Fix think-o.
ldionne added inline comments.
include/llvm/Support/type_traits.h
59

I'm not sure what the intent is, but std::tuple is not a POD even when its elements are -- it typically applies the EBO and I'm pretty sure it could actually use other tricks that would not make it a POD. Specifically, that would make it not Standard Layout AFAICT.

ldionne added inline comments.Sep 10 2018, 1:02 PM
include/llvm/Support/type_traits.h
59
jfb planned changes to this revision.Sep 10 2018, 1:13 PM
jfb added inline comments.
include/llvm/Support/type_traits.h
59

Interesting! The idea is to work around GCC < 5 not having std::is_trivially_copyable... and isPodLike already says that std::pair matches isPodLike which is actually not true as you demonstrate.

My use case was bit_cast of std::array which *is* trivially copyable.

So now I have to change isPodLike to remove the std::pair overload, not add one for std::tuple, and do add one for std::array.

I'm therefore not just making it more capable, I'm also fixing a bug with std::pair.

To make everything worst, this is slightly inconsistent because of GCC 5! Methink we really want to upgrade minimum compiler past GCC 5. This BoF sounds like a great place to discuss it:
https://llvm.org/devmtg/2018-10/talk-abstracts.html#bof3

jfb abandoned this revision.Sep 10 2018, 1:18 PM
jfb added inline comments.
include/llvm/Support/type_traits.h
59

I think I don't want to change isPodLike anymore. It's a crappy alternative to std::is_trivially_copyable. I think I want to special-case bit_cast instead to only check sizeof and builtin (if available) on GCC < 5, and rely on bots to catch bad usage otherwise (that is, most developers will do the full check, and outdated developers will break the bots).

I think isPodLike should die, but separately.

jfb added a comment.Sep 10 2018, 1:38 PM

Let's do D51888 instead.