- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Questions about C++ exceptions and signals.
Operating System - OpenVMS
1753620
Members
6438
Online
108797
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 05:46 AM
тАО09-08-2009 05:46 AM
Re: Questions about C++ exceptions and signals.
Boris:
I just wanted to point out that the compiler option /exception=implicit applies to Alpha only. The documentation seems to be saying that Itanium doesn't need it, not that Itanium doesn't support it.
Dennis:
I think the fact that you can't throw out of a signal handler is something different. My understanding is that C++ try-throw-catch is implemented using OpenVMS condition handlers, so throwing an exception from a condition handler is like signalling from a condition handler, which you can't do. This is just like in C++: if an exception is thrown, and another exception gets thrown (due to unwinding the stack, for example) before the catch block is reached, the program terminates.
Here's an example where you can see how the access violation leads to a violation of exception safety:
#include
#include
#include
class A
{
public:
A() { cout << "A()" << endl; };
~A() { cout << "~A()" << endl; };
};
int foo()
{
try {
A a;
int x = *(int*)0;
return x;
} catch (struct chf$signal_array &obj) {
cout << "Caught in foo:" << obj.chf$l_sig_name << endl;
}
return 0;
}
int main ()
{
try {
int i = foo();
} catch (struct chf$signal_array &obj) {
cout << "Caught in main:" << obj.chf$l_sig_name << endl;
}
return 0;
}
If you run this as is, you get the following:
A()
Caught in foo:12
This is bad. No call to ~A().
Now comment out the line "A a;".
The output changes to:
Caught in main:12
I just wanted to point out that the compiler option /exception=implicit applies to Alpha only. The documentation seems to be saying that Itanium doesn't need it, not that Itanium doesn't support it.
Dennis:
I think the fact that you can't throw out of a signal handler is something different. My understanding is that C++ try-throw-catch is implemented using OpenVMS condition handlers, so throwing an exception from a condition handler is like signalling from a condition handler, which you can't do. This is just like in C++: if an exception is thrown, and another exception gets thrown (due to unwinding the stack, for example) before the catch block is reached, the program terminates.
Here's an example where you can see how the access violation leads to a violation of exception safety:
#include
#include
#include
class A
{
public:
A() { cout << "A()" << endl; };
~A() { cout << "~A()" << endl; };
};
int foo()
{
try {
A a;
int x = *(int*)0;
return x;
} catch (struct chf$signal_array &obj) {
cout << "Caught in foo:" << obj.chf$l_sig_name << endl;
}
return 0;
}
int main ()
{
try {
int i = foo();
} catch (struct chf$signal_array &obj) {
cout << "Caught in main:" << obj.chf$l_sig_name << endl;
}
return 0;
}
If you run this as is, you get the following:
A()
Caught in foo:12
This is bad. No call to ~A().
Now comment out the line "A a;".
The output changes to:
Caught in main:12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 07:10 AM
тАО09-08-2009 07:10 AM
Re: Questions about C++ exceptions and signals.
"
I just wanted to point out that the compiler option /exception=implicit applies to Alpha only.
"
This is exactly my point. This option is not available on Itanium and without it, catching non-C++ exceptions in a C++ catch block is not guaranteed to work.
"
The documentation seems to be saying that Itanium doesn't need it, not that Itanium doesn't support it.
"
If this is how the documentation describes it, the documentation should be corrected. I suggest, you contact your HP customer support representative for the definitive answer.
"
Here's an example where you can see how the access violation leads to a violation of exception safety.
"
The C++ standard has no provisions about "exception safety" of non-C++ exceptions. You are relying on VMS extension which is not fully implemented on VMS Itanium.
Thanks,
-Boris
I just wanted to point out that the compiler option /exception=implicit applies to Alpha only.
"
This is exactly my point. This option is not available on Itanium and without it, catching non-C++ exceptions in a C++ catch block is not guaranteed to work.
"
The documentation seems to be saying that Itanium doesn't need it, not that Itanium doesn't support it.
"
If this is how the documentation describes it, the documentation should be corrected. I suggest, you contact your HP customer support representative for the definitive answer.
"
Here's an example where you can see how the access violation leads to a violation of exception safety.
"
The C++ standard has no provisions about "exception safety" of non-C++ exceptions. You are relying on VMS extension which is not fully implemented on VMS Itanium.
Thanks,
-Boris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 04:35 PM
тАО09-08-2009 04:35 PM
Re: Questions about C++ exceptions and signals.
>I think the fact that you can't throw out of a signal handler is something different.
Of course it is directly related on HP-UX. The Standard says you can't do that and we have implemented the aC++ runtime to assume that's true.
>My understanding is that C++ try-throw-catch is implemented using OpenVMS condition handlers
On HP-UX, they don't exist. And if they did, it wouldn't help. I.e. we assume only calls need to handle EH activity, only throws cause exceptions. Not loads/stores or floating point operations.
>so throwing an exception from a condition handler is like signalling from a condition handler, which you can't do. This is just like in C++: if an exception is thrown, and another exception gets thrown
I guess I don't know what a condition handler is.
Of course it is directly related on HP-UX. The Standard says you can't do that and we have implemented the aC++ runtime to assume that's true.
>My understanding is that C++ try-throw-catch is implemented using OpenVMS condition handlers
On HP-UX, they don't exist. And if they did, it wouldn't help. I.e. we assume only calls need to handle EH activity, only throws cause exceptions. Not loads/stores or floating point operations.
>so throwing an exception from a condition handler is like signalling from a condition handler, which you can't do. This is just like in C++: if an exception is thrown, and another exception gets thrown
I guess I don't know what a condition handler is.
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP