Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-06-15 11:49:54


Markus Schöpflin <markus.schoepflin_at_[hidden]> writes:

> Hello,
>
> unfortunately boost.python is unusable on that platform because most of the
> tests fail at runtime with a stack overflow. The reason is illustrated in
> the following code sample:
>
> ---%<---
> void foo(int);
> template <class T> void foo(T) { foo(0); }
>
> int main()
> {
> foo(0);
> }
> --->%---
>
> When compiling this with CXX 6.5, the code compiles and links cleanly,
> despite the fact that the overload for foo() is not defined. Instead the
> compiler instantiates foo<int>(int) and then uses the instantiation for the
> call to foo() which of course leads to a stack overflow.

I'm confused. I was pretty sure Ralf was running Boost.Python on that
compiler. Ralf?

> I had a look at the standard what should happen in this case, but after
> reading [temp.over] I'm not really sure if we don't indeed end up with two
> candidate functions for the overload resolution of foo(), one being the
> overload itself and the other the specialization of the function template
> for int. Could anyone please clarify this?

The non-template function should be preferred. The function template
should never even get instantiated.

> As for a possible workaround, replacing the overload with a specialization
> of the function template would work, AFAICT. Would such a patch be accepted?

If it's a localized patch somewhere in Boost.Python, it might. But
this sounds like the sort of problem that would require sweeping
fixes. No?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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