Request for small test in CW 9.2

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

On Jun 14, 2004, at 1:18 PM, Joaquín Mª López Muñoz wrote:
*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.
With "ISO C++ Template Parser" turned on I get: 3200 calling A::bar inside A::bar ~foo calling B::bar inside B::bar ~foo I added: std::cout << std::hex << __MWERKS__ << '\n'; in the hope that that would be helpful. -Howard

Howard Hinnant ha escrito: [...]
With "ISO C++ Template Parser" turned on I get:
3200 calling A::bar inside A::bar ~foo calling B::bar inside B::bar ~foo
I added:
std::cout << std::hex << __MWERKS__ << '\n';
in the hope that that would be helpful.
Well, from your test and that of Chris, seems like the problem is fixed starting at CW9.0. The patch will be applied then only to 8.3 and below. Thanks for the feedback. Best, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

on 6/14/04 1:18 PM, Joaquín Mª López Muñoz at joaquin@tid.es wrote:
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
I get this output when I build your test app with "ISO C++ Template Parser" under CWP 9.2. Chris
participants (3)
-
Chris Little
-
Howard Hinnant
-
Joaquín Mª López Muñoz