Boost logo

Boost :

From: Peder Holt (peder.holt_at_[hidden])
Date: 2006-02-08 01:47:48


On 2/7/06, Neal Becker <ndbecker2_at_[hidden]> wrote:
> Andy Little wrote:
>
> [...]
> > gcc 4.0.1 error:
> >
> > test.cpp: In member function 'my::udt<__typeof__
> > (boost::type_of::ensure_obj(((T)(1) + (T1)(1))))>
> > my::udt<T>::operator+(const my::udt<T1>&) const [with T1 = double, T =
> > int]': test.cpp:26: internal compiler error: in write_type, at
> > cp/mangle.c:1646 Please submit a full bug report,
> > with preprocessed source if appropriate.
> > See <URL:http://gcc.gnu.org/bugs.html> for instructions.
> >
>
>
> I reported this and got this response (FYI):
> ------- Additional Comments From jakub_at_[hidden] 2006-02-07 11:15 EST -------
> This is a well known very old problem. Simply avoid using typeof in template
> arguments.
>

This is not always simple, though. The implementation of LVALUE_TYPEOF
relies on using a typeof statement as a template argument, making it
very hard to implement a generalized lvalue-preserving typeof for GCC:
#define BOOST_LVALUE_TYPEOF(expr)\
boost::type_of::decorate_type< \
        BOOST_TYPEOF(expr), \
        sizeof(*boost::type_of::classify_expression(expr)) \
>::type

It also prevents us from removing the template version of BOOST_TYPEOF:
BOOST_TYPEOF_TPL, which adds 'typename' where needed.
This is because we cannot add typename before __typeof__(expr):

Emulation:
<Code>
#define BOOST_TYPEOF(expr) \
boost::type_of::decode_begin<BOOST_TYPEOF_ENCODED_VECTOR(Expr) >::type

#define BOOST_TYPEOF_TPL(expr) typename BOOST_TYPEOF(expr)
</Code>

GCC:
<Code>
#define BOOST_TYPEOF(expr) __typeof__(expr)
#define BOOST_TYPEOF_TPL(expr) BOOST_TYPEOF(expr)
</Code>

so:
The suggested workaround for GCC (that would allow us to remove
BOOST_TYPEOF_TPL)
#define BOOST_TYPEOF(expr) boost::type_of::identity<__typeof__(expr)>::type
also fails because of this problem :(

Regards
Peder
>
> _______________________________________________
> 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