| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-2.6 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <25645396.post@talk.nabble.com> |
| Date: | Mon, 28 Sep 2009 07:38:40 -0700 (PDT) |
| From: | zevel12 <zg DOT nab AT zevelx DOT net> |
| To: | cygwin AT cygwin DOT com |
| Subject: | gcc 4.3.2 rethrow exception |
| MIME-Version: | 1.0 |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
Rethrowing an exception in Cygwin's gcc 4.3.2 causes an abort. This works
with gcc 3.4.4 and in Linux with gcc 4. Below is an example that is compiled
as: gcc rethrow.cpp -lstdc++.
Any insights would be appreciated.
-z
-----------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
void test2() throw(int)
{
throw 2;
}
int rethrow_fail() throw(int)
{
try
{
test2();
return(0);
}
catch(int i)
{
throw; // this throw causes the program to abort
}
}
int rethrow_ok() throw(int)
{
int n;
try
{
test2();
return(0);
}
catch(int i)
{
n = i;
}
throw n; // this throw works since outside of the catch
}
int main()
{
// -------------------------------------------------------
// the following works with the exception caught
// -------------------------------------------------------
try
{
printf("rethrow_ok return=%d\n", rethrow_ok());
}
catch(int n)
{
printf("rethrow_ok exception=%d\n", n);
}
// -------------------------------------------------------
// the following will fail with the program aborting when
// build with Cygwin gcc 4.3.2
// -------------------------------------------------------
try
{
printf("rethrow_fail return=%d\n", rethrow_fail());
}
catch(int n)
{
printf("rethrow_fail exception=%d\n", n);
}
return(0);
}
// override of abort so can trap abort
extern "C" void abort(void)
{
printf("abort\n");
exit(1);
}
-----------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/gcc-4.3.2-rethrow-exception-tp25645396p25645396.html
Sent from the Cygwin list mailing list archive at Nabble.com.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |