Skip to content

Instantly share code, notes, and snippets.

@komiga
Last active December 15, 2015 07:59
Show Gist options
  • Select an option

  • Save komiga/5227043 to your computer and use it in GitHub Desktop.

Select an option

Save komiga/5227043 to your computer and use it in GitHub Desktop.
Broke the Clangmaster. Again.
#include <cstddef>
using E = int;
using U = E[];
struct H {
E b[1]{E{1}};
U const& ref{reinterpret_cast<U const&>(b)};
operator U const&() const {
return reinterpret_cast<U const&>(b);
}
};
signed main() {
H const h{};
// Works with h.ref
U const& ref{h};
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment