|
Boost : |
From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2004-06-14 12:18:53
During the porting of my library, I found the following compiler
bug in CW 8.3:
**BEGIN PROGRAM**
#include <iostream>
struct foo
{
foo(){}
foo(const foo&){}
~foo()
{
std::cout<<"~foo"<<std::endl;
}
};
template<typename T>
struct A
{
static void bar()
{
const foo& f=foo();
std::cout<<"inside A::bar"<<std::endl;
}
};
struct B
{
static void bar()
{
const foo& f=foo();
std::cout<<"inside B::bar"<<std::endl;
}
};
int main()
{
std::cout<<"calling A::bar"<<std::endl;
A<int>::bar();
std::cout<<"calling B::bar"<<std::endl;
B::bar();
return 0;
}
**END PROGRAM**
*Without* enabling the option "ISO C++ Template Parser", everything
works dandy and the program output is:
calling A::bar
inside A::bar
~foo
calling B::bar
inside B::bar
~foo
But if I enable the "ISO C++ Template Parser", the output becomes:
calling A::bar
~foo
inside A::bar
calling B::bar
inside B::bar
~foo
Which is AFAICS a flagrant bug (note that ~foo() is called before
A::bar()
scope ends.)
Fortunately, I know how to patch this in CW 8.3 with some pragmas.
I'd be grateful if someone with access to CW 9.2 can check whether the
error persists in this newer version of the compiler, so as to extend
(or not)
the patch to cover it as well. Remember, the problem only shows when
the "ISO C++ Template Parser" is turned on.
Thanks,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk