This is an archive of the discontinued LLVM Phabricator instance.

[ADT] restrict bit_cast to trivially-constructible To
ClosedPublic

Authored by jfb on Sep 20 2018, 4:53 PM.

Details

Summary

As discussed in r341853 by blaikie, the reinterpret_cast was technically an aliasing violation. Restrict our bit_cast implementation to To which are trivially-constructible (and note the existing restriction to constexpr). Once we move to C++17 we can use a version of bit_cast without these restrictions, or if we care we can SFINAE a different implementation when To isn't trivially-constructible.

Diff Detail

Event Timeline

jfb created this revision.Sep 20 2018, 4:53 PM
dblaikie accepted this revision.Sep 20 2018, 4:56 PM

Looks good - thanks a bunch!

This revision is now accepted and ready to land.Sep 20 2018, 4:56 PM
This revision was automatically updated to reflect the committed changes.
jfb added a comment.Sep 20 2018, 10:39 PM

Had to revert, this was in GCC 5.1 only. I'll fix tomorrow.

jfb added a comment.Sep 21 2018, 7:33 AM

Re-landed as r342739.