* c++ char exceptions
@ 2002-04-23 1:15 Robert Collins
0 siblings, 0 replies; 8+ messages in thread
From: Robert Collins @ 2002-04-23 1:15 UTC (permalink / raw)
To: Cygwin
I don't know if this is a cygwin issue or if I am doing something
fundamentally wrong...
int
main (int argc, char **argv)
{
try
{
throw "catch this";
}
catch (char *message)
{
return 1;
}
return 0;
}
coredumps on me. Throwing int's works fine. Throwing (string) "foo"
works fine.
Anyway, this is partly for the archives, partly for curiosity.
Rob
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: c++ char exceptions
@ 2002-04-23 1:18 Danny Smith
0 siblings, 0 replies; 8+ messages in thread
From: Danny Smith @ 2002-04-23 1:18 UTC (permalink / raw)
To: cygwin
Robert wrote:
>
> I don't know if this is a cygwin issue or if I am doing something
> fundamentally wrong...
>
You threw const char*
int
main (int argc, char **argv)
{
try
{
throw "catch this";
}
catch (const char *message)
// ^^^^^
{
return 1;
}
return 0;
}
>
http://messenger.yahoo.com.au - Yahoo! Messenger
- A great way to communicate long-distance for FREE!
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: c++ char exceptions
@ 2002-04-23 1:21 Robert Collins
0 siblings, 0 replies; 8+ messages in thread
From: Robert Collins @ 2002-04-23 1:21 UTC (permalink / raw)
To: Danny Smith, cygwin
> -----Original Message-----
> From: Danny Smith [mailto:danny_r_smith_2001@yahoo.co.nz]
> Sent: Tuesday, April 23, 2002 6:11 PM
>
> Robert wrote:
> >
> > I don't know if this is a cygwin issue or if I am doing something
> > fundamentally wrong...
> >
>
> You threw const char*
Sigh. Blush. I should have caught (no pun intended) that.
Thanks Danny.
Rob
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: c++ char exceptions
@ 2002-04-23 1:22 Michael D. Crawford
0 siblings, 0 replies; 8+ messages in thread
From: Michael D. Crawford @ 2002-04-23 1:22 UTC (permalink / raw)
To: cygwin
It aborts with g++ 2.95.4 on Debian PowerPC Linux too.
But if I compile it with CodeWarrior 6 on Windows it runs normally, doesn't
crash, and gives the exit code of 1.
I think CodeWarrior is correct, and that this is a bug in g++, but not in cygwin.
Mike
Thus it was written:
I don't know if this is a cygwin issue or if I am doing something
fundamentally wrong...
int
main (int argc, char **argv)
{
try
{
throw "catch this";
}
catch (char *message)
{
return 1;
}
return 0;
}
coredumps on me. Throwing int's works fine. Throwing (string) "foo"
works fine.
---
Michael D. Crawford
GoingWare Inc. - Expert Software Development and Consulting
http://www.goingware.com/
crawford@goingware.com
Tilting at Windmills for a Better Tomorrow.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: c++ char exceptions
@ 2002-04-23 1:48 Michael D. Crawford
2002-04-23 5:31 ` Lassi A. Tuura
0 siblings, 1 reply; 8+ messages in thread
From: Michael D. Crawford @ 2002-04-23 1:48 UTC (permalink / raw)
To: cygwin
> You threw const char*
That shouldn't matter. At the worst it should mean that the exception is not
caught by any of the catch clauses given, so the "return 0" would be taken.
The only thing that should happen to an exception object after you're done with
it is that objects thrown by value are destroyed. In this case the pointer
would be destroyed, but the memory it points to should not be deleted or anything.
Usually throwing a pointer is not what you really want to do, but it shouldn't
cause a crash.
Michael D. Crawford
GoingWare Inc. - Expert Software Development and Consulting
http://www.goingware.com/
crawford@goingware.com
Tilting at Windmills for a Better Tomorrow.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: c++ char exceptions
2002-04-23 1:48 Michael D. Crawford
@ 2002-04-23 5:31 ` Lassi A. Tuura
2002-04-25 1:00 ` Michael D. Crawford
0 siblings, 1 reply; 8+ messages in thread
From: Lassi A. Tuura @ 2002-04-23 5:31 UTC (permalink / raw)
To: Michael D. Crawford; +Cc: cygwin
> That shouldn't matter. At the worst it should mean that the exception is not
> caught by any of the catch clauses given, so the "return 0" would be taken.
It does matter -- in this case the exception was not handled, and
therefore terminate() gets called, which probably called abort(). That
is, the "return 0" is never taken, the exception leaks outside main().
//lat
--
Behold the turtle. He makes progress only when
he sticks his neck out. --James Bryant Conant
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: c++ char exceptions
2002-04-23 5:31 ` Lassi A. Tuura
@ 2002-04-25 1:00 ` Michael D. Crawford
0 siblings, 0 replies; 8+ messages in thread
From: Michael D. Crawford @ 2002-04-25 1:00 UTC (permalink / raw)
To: Lassi A. Tuura; +Cc: cygwin
You're right, I wasn't thinking, if an exception isn't caught before it
leaves main it aborts the program.
So maybe codewarrior has a bug!
Mike
On Tue, 2002-04-23 at 06:33, Lassi A. Tuura wrote:
> > That shouldn't matter. At the worst it should mean that the exception is not
> > caught by any of the catch clauses given, so the "return 0" would be taken.
>
> It does matter -- in this case the exception was not handled, and
> therefore terminate() gets called, which probably called abort(). That
> is, the "return 0" is never taken, the exception leaks outside main().
>
> //lat
> --
> Behold the turtle. He makes progress only when
> he sticks his neck out. --James Bryant Conant
>
> --
> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting: http://cygwin.com/bugs.html
> Documentation: http://cygwin.com/docs.html
> FAQ: http://cygwin.com/faq/
>
--
Michael D. Crawford
GoingWare Inc. - Expert Software Development and Consulting
crawford@goingware.com
http://www.goingware.com/
Tilting at Windmills for a Better Tomorrow.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: c++ char exceptions
@ 2002-04-23 1:54 Robert Collins
0 siblings, 0 replies; 8+ messages in thread
From: Robert Collins @ 2002-04-23 1:54 UTC (permalink / raw)
To: Michael D. Crawford, cygwin
> -----Original Message-----
> From: Michael D. Crawford [mailto:crawford@goingware.com]
> Sent: Tuesday, April 23, 2002 6:24 PM
>
> Usually throwing a pointer is not what you really want to do,
> but it shouldn't
> cause a crash.
Is it worth putting this up as a bug on the gcc bugs database?
Rob
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-04-25 5:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-23 1:15 c++ char exceptions Robert Collins
2002-04-23 1:18 Danny Smith
2002-04-23 1:21 Robert Collins
2002-04-23 1:22 Michael D. Crawford
2002-04-23 1:48 Michael D. Crawford
2002-04-23 5:31 ` Lassi A. Tuura
2002-04-25 1:00 ` Michael D. Crawford
2002-04-23 1:54 Robert Collins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).