[cfe-commits] [PATCH] Fix for reinterpret_cast (bug 11747)

Aaron Ballman aaron at aaronballman.com
Mon Jan 16 20:38:39 PST 2012


On Sun, Jan 15, 2012 at 9:05 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Sun, Jan 15, 2012 at 1:45 PM, Aaron Ballman <aaron at aaronballman.com> wrote:
>> This is a patch for fixing 11747, allowing reinterpret_cast to "cast"
>> where the source and destination types are the same as per
>> [expr.reinterpret.cast]p2.  The fix itself is fairly simple -- the
>> code was already there, it just needed to be moved up slightly since
>> the previous check was for source and dest being pointers.
>
> C++11 [expr.reinterpret.cast]p2 is as follows:
>
> The reinterpret_cast operator shall not cast away constness (5.2.11).
> An expression of integral, enumeration, pointer, or pointer-to-member
> type can be explicitly converted to its own type; such a cast yields
> the value of its operand.

Attached is a new patch to hopefully better address this, as well as
some additional test cases.

HTH!

~Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: reinterpret_cast.patch
Type: application/octet-stream
Size: 3563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120116/5e14e4a9/attachment.obj>


More information about the cfe-commits mailing list