Boost logo

Boost :

Subject: Re: [boost] [PATCH] [exception] Replace C cast with reinterpret_cast for Metrowerks C++
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-03-05 05:07:42


On 5 Mar 2011, at 09:48, Joshua Juran wrote:

> Metrowerks C++ 2.4.1 thinks the type of (T*)0 is T, rather than T*. But reinterpret_cast works fine.

That is an incredibly strange bug.

This also introduced a bug. (T*)0 is the expected way to get a null pointer of type T*. A reinterpret_cast is incorrect (although in practice likely to work on most machines / compiles)

Does static_cast work? That would be fine instead of the C-style cast.

Chris

>
> ---
>
> This patch doesn't affect the compilation of g++ 4.0.1.
>
> diff --git boost/exception/exception.hpp boost/exception/exception.hpp
> index fd516dd..87063af 100644
> --- boost/exception/exception.hpp
> +++ boost/exception/exception.hpp
> @@ -334,7 +334,7 @@ boost
> struct
> enable_error_info_return_type
> {
> - typedef typename enable_error_info_helper<T,sizeof(exception_detail::dispatch_boost_exception((T*)0))>::type type;
> + typedef typename enable_error_info_helper<T,sizeof(exception_detail::dispatch_boost_exception(reinterpret_cast<T*>(0)))>::type type;
> };
> }
>
>
>
> <reinterpret_cast-for-MWC.patch>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk