[PATCH] Add __builtin_addressof

Richard Smith richard at metafoo.co.uk
Wed Jul 10 17:40:08 PDT 2013

The attached patch adds a __builtin_addressof, that performs the same
functionality as the built-in & operator (ignoring any overloaded
operator& for the type). The purpose of this builtin is for use in
std::addressof, to allow it to be made constexpr; the existing
implementation technique (reinterpret_cast to some reference type,
take address, reinterpert_cast back) does not permit this because
reinterpret_cast between reference types is not permitted in a
constant expression in C++11 onwards.

Any objections?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: builtin-addressof.diff
Type: application/octet-stream
Size: 14906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130710/e48dbcbc/attachment.obj>

More information about the cfe-commits mailing list