Very strange try/catch problem. Please help!

  • Thread starter Michael Kantarovich
  • Start date
M

Michael Kantarovich

Hello,

I have a class, that in all it's methods, following code won't reach
the catch statment!! All other classes in the project are working fine.

....

try {
throw std::exception();
}
catch (...) {
cout << "I am here." << endl; //THIS LINE IS NEVER REACHED.
//IN STEAD OF REACHING THIS LINE,
//CONTROL IS PASSED TO HIGHER CATCH STATMENT
//IN THE CALLER, BUT NOT IN THIS CLASS/METHOD!
}

....

I can't imagine what is wrong ... i tried a lot of things, all without any effect.

I am using Solaris 8 and SunCC 5.5 (Compiler Collection 8).
Thanks a lot for help!
 
G

Gianni Mariani

Michael said:
Hello,

I have a class, that in all it's methods, following code won't reach
the catch statment!! All other classes in the project are working fine.

...

try {
throw std::exception();
}
catch (...) {
cout << "I am here." << endl; //THIS LINE IS NEVER REACHED.
//IN STEAD OF REACHING THIS LINE,
//CONTROL IS PASSED TO HIGHER CATCH STATMENT
//IN THE CALLER, BUT NOT IN THIS CLASS/METHOD!
}

...

I can't imagine what is wrong ... i tried a lot of things, all without any effect.

I am using Solaris 8 and SunCC 5.5 (Compiler Collection 8).
Thanks a lot for help!

Suggestion: Post compilable code.

The code below seems to do what you expect on GCC 3.3.1.

I think you're right, I think this is a compiler bug. You'll need to get
some help from SUN. Maybe they have a patch.


#include <iostream>


void foo()
{

try {
throw std::exception();
}
catch (...) {
std::cout << "I am here." << std::endl; //NOT REACHED.

}

}


int main()
{

try {
foo();
}
catch (...) {
std::cout << "I OUTA am here." << std::endl;
}

}
 
M

Michael Kantarovich

Gianni Mariani said:
Suggestion: Post compilable code.

The code below seems to do what you expect on GCC 3.3.1.

I think you're right, I think this is a compiler bug. You'll need to get
some help from SUN. Maybe they have a patch.


#include <iostream>


void foo()
{

try {
throw std::exception();
}
catch (...) {
std::cout << "I am here." << std::endl; //NOT REACHED.

}

}


int main()
{

try {
foo();
}
catch (...) {
std::cout << "I OUTA am here." << std::endl;
}

}

Hi, Thanks for help!
But how do you explain that this code works fine in other classes (in
different archives (.a) ) ? ...
 
M

Michael Kantarovich

Gianni Mariani said:
Suggestion: Post compilable code.

The code below seems to do what you expect on GCC 3.3.1.

I think you're right, I think this is a compiler bug. You'll need to get
some help from SUN. Maybe they have a patch.


#include <iostream>


void foo()
{

try {
throw std::exception();
}
catch (...) {
std::cout << "I am here." << std::endl; //NOT REACHED.

}

}


int main()
{

try {
foo();
}
catch (...) {
std::cout << "I OUTA am here." << std::endl;
}

}

Hi,
I found out that the problem is in one of my libraries, and others
work fine.
Does anyone has the experiense with SunCC 5.5 Compiler. It seems to me
that it is some kind of bug, but i can't find out what is it ... .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top