Boost logo

Boost :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-09-27 02:43:58


On Monday 26 Sep 2005 Darren Cook <darren_at_[hidden]> wrote:

> Has anyone had trouble with complex template code when moving from gcc
> 3.4 to gcc 4.0.1? I don't see anything in the release notes that matches
> the problem I'm getting, which looks like this (fuller error message
> attached below):
>
> no matching function for call to
>
boost::smart_assert::Private::smart_assert_alloc<boost::smart_assert::assert_context_func>::destroy(std::pair<const
> int, boost::smart_assert::assert_context_func>*)
>
> candidates are:
>   void __gnu_cxx::__mt_alloc_base<_Tp>::destroy(_Tp*)
>   [with _Tp = boost::smart_assert::assert_context_func]

Darren, I didn't look in detail at your code. There is however a very
significant change in how GCC determines template ambiguity that was
introduced between gcc-4.0.0 and gcc-4.0.1

Have a look at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12536

This changes the handling of template partial ordering to be compatible with
C++ standard DR214.

I'm not sure that it might not have introduced some other side effects. To
determine this I would have to understand what the new text of the standard
(with DR214) specifies. And this is not so easy :-)
A the moment I have a test case as a candidate for a GCC bug report.

// Effect of DR214 FIX (Bug 19203) on 2 simple function template cases
template <class E>
class expression {
};

// ef - deduction of E is via expression
template<class E>
void ef (expression<E> e);
template<class R, class E>
void ef (expression<E> e);

// sf - deduction of S is simple
template<class S>
void sf (S s);
template<class R, class S>
void sf (S s);
void test()
{
    expression<int> a;
    ef (a);          // ok
    ef<char> (a);    // ok
    ef<int> (a);     // Ambiguous in 4.0.1 when R == E

    sf (a);          // ok
    sf<char> (a);   // ok
    sf<int> (a);    // unambiguous
}

I believe there is nothing fundementaly different in deducing the two forms of
template parameters 'expression<E>' OR 'S'.

All the best,
        Michael Stevens


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