Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-07-10 12:27:12


Markus Werle wrote:
> Hi!

Hi Markus,

>
> Though Intel C++ compiles this without complaint
> gcc fails with ICE on this code snippet, which is
> preprocessor output of boost code:
>
> struct void_ {};
>
> template<
> bool C
> , typename T1
> , typename T2
> >
> struct if_c
> {
> typedef T1 type;
> };
>
> template<
> typename T1
> , typename T2
> >
> struct if_c<false,T1,T2>
> {
> typedef T2 type;
> };
>
>
> template<
> typename C = void_
> , typename T1 = void_
> , typename T2 = void_
> >
> struct if_
> {
> private:
> typedef if_c<
> static_cast<bool>(C::value)
> , T1
> , T2
> > almost_type_;
>
> public:
> typedef typename almost_type_::type type;
>
>
> };
>
>
> int main() {
> typedef if_<true_, double, int>::type D;
> D d;
> }

Hmm, seems like a regression to me. The above compiles fine on gcc 3.2. It
won't compile on 2.95.x, but it doesn't matter because for that one the
output would be different - the original line responsible for the static
cast form is

          BOOST_MPL_AUX_STATIC_CAST(bool,
BOOST_MPL_AUX_VALUE_WKND(C)::value)

and it will produce either '(bool)(C::value)' or
'static_cast<bool>(C::value)' depending on which form the compiler is more
happy with.

I suggest you report the failure as a regression to gcc developers and make
a local modification to "boost/mpl/aux_/static_cast.hpp" to workaround the
bug meanwhile.

Aleksey


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