[Patch] Disallow reinterpret_cast from pointer to bool on Windows (PR16222)

Hans Wennborg hans at chromium.org
Wed Jun 5 07:21:25 PDT 2013


Yeah, and we had code in Chromium that actually did this
reinterpret_cast, which was caught by Clang crashing on it :) So I
really do want to error here.

On Wed, Jun 5, 2013 at 3:10 PM, Reid Kleckner <rnk at google.com> wrote:
> For the record, MSVC does a truncation (it doesn't do any funny
> reinterpret-really-means-static cast stuff).  256 byte aligned pointers do
> become false.  =P  Clang should probably just error out even if MSVC
> accepts.
>
>
> On Wed, Jun 5, 2013 at 9:31 AM, Hans Wennborg <hans at chromium.org> wrote:
>>
>> Hi all,
>>
>> This patch makes Clang disallow reinterpret_cast from pointer to bool
>> on Windows.
>>
>> Currently, it's allowed by accident and later triggers an exception.
>> Support was added in r131201 to allow conversion from pointers to
>> integral types on windows since this is apparently used in system
>> headers. However, converting pointers to bool is already supported in
>> a civilized manner via static_cast and c-style cast. Allowing it
>> through reinterpret_cast seems like a bad idea.
>>
>> Please take a look.
>>
>> Thanks,
>> Hans
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>



More information about the cfe-commits mailing list