<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Checked Exceptions]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>gibt es in C++ auch eine Möglichkeit vom Compiler checken zu lassen,<br />
ob alle Exceptions gecatcht werden? Oder nur bei bestimmten Compilern?<br />
Ich verwende gcc unter KDevelop</p>
<p>Kann ich irgendwie den Methoden-Stack ausgeben lassen wie in Java?</p>
<p>Gruß,<br />
CSpille</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/118550/checked-exceptions</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 20:12:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/118550.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 21 Aug 2005 20:17:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Checked Exceptions on Sun, 21 Aug 2005 20:17:38 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>gibt es in C++ auch eine Möglichkeit vom Compiler checken zu lassen,<br />
ob alle Exceptions gecatcht werden? Oder nur bei bestimmten Compilern?<br />
Ich verwende gcc unter KDevelop</p>
<p>Kann ich irgendwie den Methoden-Stack ausgeben lassen wie in Java?</p>
<p>Gruß,<br />
CSpille</p>
]]></description><link>https://www.c-plusplus.net/forum/post/855656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/855656</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 21 Aug 2005 20:17:38 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Sun, 21 Aug 2005 21:21:00 GMT]]></title><description><![CDATA[<p>Afaik nein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/855689</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/855689</guid><dc:creator><![CDATA[FireFlow]]></dc:creator><pubDate>Sun, 21 Aug 2005 21:21:00 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Sun, 21 Aug 2005 22:42:29 GMT]]></title><description><![CDATA[<p>CSpille schrieb:</p>
<blockquote>
<p>gibt es in C++ auch eine Möglichkeit vom Compiler checken zu lassen,<br />
ob alle Exceptions gecatcht werden?</p>
</blockquote>
<p>Imo dürfte sowas nicht möglich sein. Wenn du aber sichergehen willst, dass alle Exceptions gefangen werden, dann bau ein catch (...) in main ein.</p>
<p>CSpille schrieb:</p>
<blockquote>
<p>Kann ich irgendwie den Methoden-Stack ausgeben lassen wie in Java?</p>
</blockquote>
<p>Bin mir zwar nicht ganz sicher, was du mit Methoden-Stack meinst. Falls du damit den Call-Stack meinst, ja das geht. Allerdings nur mit einigen nachträglichen Eingriffen. Für bestehenden Code geht das nicht, zumindest nicht portabel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/855730</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/855730</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Sun, 21 Aug 2005 22:42:29 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 00:17:58 GMT]]></title><description><![CDATA[<p>Kannst du mal erklaeren wie du an den Call-Stack kommst? Weisst du irgendwie an welcher Adresse der liegt, bzw. vor oder nach welchem Segment, sodass du dir die Adresse errechnen kannst?<br />
Würd mich mal interessieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/855757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/855757</guid><dc:creator><![CDATA[Ger001]]></dc:creator><pubDate>Mon, 22 Aug 2005 00:17:58 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 05:30:55 GMT]]></title><description><![CDATA[<p>Theoretisch würde die Exception-Abfang-Erzwingung funktionieren. Aber praktisch lässt sich das in C++ schwer umsetzen. Alleine deshalb schon, weil in der Funktions/Methoden-Sig nicht stehen muß, was geworfen wird. Das kannst du also vergessen, du bist hier in der C++ Welt. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Den Callstack kann man so auch nicht ausgeben, außer man ist in der Debug-Compilierung und man baut COmpiler-Spezifische printouts ein. Aber ist auch nicht das was du eigentlich willst.</p>
<p>Bedenke eines: C++ ist eine Compiler-Sprache! D.h. zur Laufzeit bekommst du keine Informationen, RTTI ist seeeeeeeeeeeeeehr mager und kann ja sogar abgeschaltet werden (was dich ja doch stutzig machen sollte).</p>
<p>Denk C++! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/855780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/855780</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Mon, 22 Aug 2005 05:30:55 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 05:38:02 GMT]]></title><description><![CDATA[<p>Das hier sollte dir für Windows weiterhelfen.<br />
<a href="http://www.codeproject.com/threads/StackWalker.asp" rel="nofollow">http://www.codeproject.com/threads/StackWalker.asp</a><br />
Ne plattformunabhängige Lösung kenn ich nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/855782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/855782</guid><dc:creator><![CDATA[Redhead]]></dc:creator><pubDate>Mon, 22 Aug 2005 05:38:02 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 06:53:39 GMT]]></title><description><![CDATA[<p>Hilft std::uncaught_exception nur bei von std::exception abgeleiteten Objekten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/855805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/855805</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Mon, 22 Aug 2005 06:53:39 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 10:26:12 GMT]]></title><description><![CDATA[<p>Ich beschränke mich immer darauf, einer Exception __FILE__ und __LINE_ mitzugeben, dann weiß ich in main wenigstens noch, wo sie her kommt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/855961</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/855961</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 22 Aug 2005 10:26:12 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 14:18:47 GMT]]></title><description><![CDATA[<p>Ger001 schrieb:</p>
<blockquote>
<p>Kannst du mal erklaeren wie du an den Call-Stack kommst? Weisst du irgendwie an welcher Adresse der liegt, bzw. vor oder nach welchem Segment, sodass du dir die Adresse errechnen kannst?</p>
</blockquote>
<p>Der Call-Stack &quot;liegt&quot; nirgendwo, zumindest aus C++ Sicht. Entweder bauen Compiler sich diesen selbst (zwecks Debugging) oder du machst das manuell. Ersteres ist allerdings nicht portabel. Es gibt zwar noch die Möglichkeit, den Stack Speicher durchzugehen, aber dies ist vielmehr ein indirekter Call-Stack, da dort lediglich Rücksprungadressen stehen.<br />
Die einzige Möglichkeit einen relativ portablen Call-Stack zu implementieren, ist, diesen selbst zu integrieren. Dazu bastelst du dir eine Klasse, welche pro Funktion einmal instanziert wird. Welche Informationen du dort rein packst ist dir überlassen. Sinnvoll wäre zumindest der Name der Funktion. Die meisten C++ Compiler kennen C99, dh du kannst dann __func__ benutzen. Und selbst Compiler, die das nicht kennen, bieten dafür idR ein eigenes Makro bzw eine eigene Konstante an. Die erstellte Instanz wird dann in einen globalen Stack-Container gepusht und mit dem dtor wieder gepopt. Der einzige Nachteil an dieser ganzen Geschichte ist, dass du prkatisch in jeder Funktion am Beginn die Instanzierung vornehmen musst. Zwar kann man das mit 'nem Makro noch etwas anwenderfreundlicher verpacken, hinschreiben muss man es aber trotzdem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856216</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856216</guid><dc:creator><![CDATA[groovemaster]]></dc:creator><pubDate>Mon, 22 Aug 2005 14:18:47 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 15:07:48 GMT]]></title><description><![CDATA[<p>Michael E. schrieb:</p>
<blockquote>
<p>Hilft std::uncaught_exception nur bei von std::exception abgeleiteten Objekten?</p>
</blockquote>
<p>Ich bekomms net hin dass std::uncaught_exception true gibt... Das hab ich versucht:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;exception&gt;

using namespace std;

struct Error
{
    Error() {
        cout &lt;&lt; &quot;Error::Error()&quot; &lt;&lt; endl;
        if(uncaught_exception()) {
            cout &lt;&lt; &quot;Uncaught Exception in Error::Error().&quot; &lt;&lt; endl;
        }
    }

    ~Error() {
        cout &lt;&lt; &quot;Error::~Error()&quot; &lt;&lt; endl;
    }
};

struct Foo
{

    Foo() {
        cout &lt;&lt; &quot;Foo::Foo()&quot; &lt;&lt; endl;
    }

    ~Foo() {
        cout &lt;&lt; &quot;Foo::~Foo()&quot; &lt;&lt; endl;
        if(uncaught_exception()) {
            cout &lt;&lt; &quot;Uncaught Exception in Foo::~Foo().&quot; &lt;&lt; endl;
        }
    }

    template&lt;class T&gt;
    void Bar(T err) {
        cout &lt;&lt; &quot;Foo::Bar()&quot; &lt;&lt; endl;
        throw err;
    }

};

int main()
{
    try {
        Foo foo;
        foo.Bar(Error()); // foo.Bar(runtime_error(&quot;x&quot;));,
    } catch(...) {
        cout &lt;&lt; &quot;Exception handling in int main()&quot; &lt;&lt; endl;
    }
    cout &lt;&lt; &quot;End&quot;;
    cin.get();
}
</code></pre>
<p>Ausgabe (bei std-exception das selbe nur ohne Error::x meldungen)</p>
<pre><code>Foo::Foo()
Error::Error()
Foo::Bar()
Error::~Error()
Error::~Error()
Foo::~Foo()
Exception handling in int main()
Error::~Error()
End
</code></pre>
<p>Irgendwie hab ich das net erwartet... Ich dachte mehr an:</p>
<pre><code>Foo::Foo()
Foo::Bar()
Error::Error()
Uncaught Exception in Error::Error().
Foo::~Foo()
Exception handling in int main()
Error::~Error()
End
</code></pre>
<p>habs unter BCD6 getestet weil ich nix anderes da hab.<br />
may be im just stupid... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>/edit: der gcc sagt wieder was anderes TT</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856239</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856239</guid><dc:creator><![CDATA[FireFlow]]></dc:creator><pubDate>Mon, 22 Aug 2005 15:07:48 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 15:07:02 GMT]]></title><description><![CDATA[<p>groovemaster schrieb:</p>
<blockquote>
<p>Der einzige Nachteil an dieser ganzen Geschichte ist, dass du prkatisch in jeder Funktion am Beginn die Instanzierung vornehmen musst.</p>
</blockquote>
<p>Ich sage dazu nur: Aspekt Orientierte Programmierung hilft da weiter!</p>
<p><a href="http://www.aspectc.org/" rel="nofollow">http://www.aspectc.org/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/856257</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856257</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Mon, 22 Aug 2005 15:07:02 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 19:17:57 GMT]]></title><description><![CDATA[<p>FireFlow schrieb:</p>
<blockquote>
<pre><code class="language-cpp">foo.Bar(Error()); // foo.Bar(runtime_error(&quot;x&quot;));,
</code></pre>
</blockquote>
<p>Das lokale Objekt vom Typ Error wird schon vor Ausführung des Rumpfes von Foo::Bar&lt;&gt;() konstruiert. Deshalb wurde noch gar keine Exception geworfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856436</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856436</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Mon, 22 Aug 2005 19:17:57 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 22 Aug 2005 19:50:54 GMT]]></title><description><![CDATA[<p>Michael E. schrieb:</p>
<blockquote>
<p>FireFlow schrieb:</p>
<blockquote>
<pre><code class="language-cpp">foo.Bar(Error()); // foo.Bar(runtime_error(&quot;x&quot;));,
</code></pre>
</blockquote>
<p>Das lokale Objekt vom Typ Error wird schon vor Ausführung des Rumpfes von Foo::Bar&lt;&gt;() konstruiert. Deshalb wurde noch gar keine Exception geworfen.</p>
</blockquote>
<p>Ok das hab ich nun kapiert... Ich hab auch verstanden dass weil ich kein Copy C'tor hab ich mehr Dekonstruktoraufrufe hab als Konstruktoraufrufe (hoffe ich zumindest dass es daran liegt, muss nochmal testen). Nun ich habs nochmal im GCC und in VC8 getestet und da bekomm ich jeweils die Meldung `Uncaught Exception in Foo::~Foo().` - Im Borland aber nicht, ist der BCB in der Hinsicht mal wieder nicht Standardkonform oder ist das Verhalten undefined?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856467</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856467</guid><dc:creator><![CDATA[FireFlow]]></dc:creator><pubDate>Mon, 22 Aug 2005 19:50:54 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Tue, 23 Aug 2005 06:46:29 GMT]]></title><description><![CDATA[<p>Will man unter Linux einen Backtrace haben nimmt man die Funktionen aus</p>
<p>#include &lt;execinfo.h&gt;</p>
<p><a href="http://www.gnu.org/software/libc/manual/html_node/Backtraces.html" rel="nofollow">http://www.gnu.org/software/libc/manual/html_node/Backtraces.html</a></p>
<p>In unserem Projekt wird das so gemacht, dass wir nur eigene Exceptions werfen. Diese sammeln im Konstruktor die Funktionszeiger auf, die backtrace() liefert.</p>
<p>Wird die Exception dann gefangen, kann man sich den Backtrace mit Namen von backtrace_symbols() ausgeben lassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856606</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856606</guid><dc:creator><![CDATA[Ponto]]></dc:creator><pubDate>Tue, 23 Aug 2005 06:46:29 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Tue, 23 Aug 2005 06:53:10 GMT]]></title><description><![CDATA[<p>Funzt das auch im Release-Modus ohne Debug-Infos?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856612</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856612</guid><dc:creator><![CDATA[backtracing]]></dc:creator><pubDate>Tue, 23 Aug 2005 06:53:10 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Tue, 23 Aug 2005 10:13:55 GMT]]></title><description><![CDATA[<p>Fireflow:</p>
<p>ISO/IEC 14882:1998 schrieb:</p>
<blockquote>
<p>18.6.4 uncaught_exception</p>
<p>bool uncaught_exception();</p>
<p><strong>Returns:</strong> &quot;true&quot; after completing evaluation of a <em>throw-expression</em>until either completing initialization of the <em>exception-declaration</em> in the matching handler or entering &quot;unexpected()&quot; due to the throw; or after entering &quot;terminate()&quot; for any reason other than explicit call to &quot;terminate()&quot;. [<em>Note:</em> This includes stack unwinding (15.2). <em>--end note</em>]</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/856747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856747</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Tue, 23 Aug 2005 10:13:55 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Tue, 23 Aug 2005 12:06:57 GMT]]></title><description><![CDATA[<p>Kann das also nur in Dekonstruktoren true ergeben? Ich meine danach wird der Block ja sofort verlassen und in den catch-Block gesprungen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856838</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856838</guid><dc:creator><![CDATA[FireFlow]]></dc:creator><pubDate>Tue, 23 Aug 2005 12:06:57 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Tue, 23 Aug 2005 12:57:31 GMT]]></title><description><![CDATA[<p>backtracing schrieb:</p>
<blockquote>
<p>Funzt das auch im Release-Modus ohne Debug-Infos?</p>
</blockquote>
<p>Ja, kann dir aber nur das sagen, was auch vorhanden ist. Das ist dann oft recht wenig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856880</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856880</guid><dc:creator><![CDATA[Ponto]]></dc:creator><pubDate>Tue, 23 Aug 2005 12:57:31 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Tue, 23 Aug 2005 14:49:15 GMT]]></title><description><![CDATA[<p>FireFlow schrieb:</p>
<blockquote>
<p>Kann das also nur in Dekonstruktoren true ergeben?</p>
</blockquote>
<p>In deinem Fall ja.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856993</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Tue, 23 Aug 2005 14:49:15 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Tue, 23 Aug 2005 21:56:55 GMT]]></title><description><![CDATA[<p>Michael E. schrieb:</p>
<blockquote>
<p>FireFlow schrieb:</p>
<blockquote>
<p>Kann das also nur in Dekonstruktoren true ergeben?</p>
</blockquote>
<p>In deinem Fall ja.</p>
</blockquote>
<p>Hast du villeicht mal nen Beispiel wo es nicht im Dekonstruktor ist und trotzdem true ergibt? Mir fällt nix ein...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/857227</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/857227</guid><dc:creator><![CDATA[FireFlow]]></dc:creator><pubDate>Tue, 23 Aug 2005 21:56:55 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Wed, 24 Aug 2005 07:34:12 GMT]]></title><description><![CDATA[<p>Sollte man eh nie benutzen.<br />
Hier hast Du interessante Lektüre dazu:<br />
<a href="http://www.gotw.ca/gotw/047.htm" rel="nofollow">http://www.gotw.ca/gotw/047.htm</a></p>
<p>Zitat von Sutter:<br />
Is there any other good use for uncaught_exception? Discuss and draw conclusions.</p>
<p>Unfortunately, I do not know of any good and safe use for std::uncaught_exception. My advice: Don't use it.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/857316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/857316</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Wed, 24 Aug 2005 07:34:12 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Wed, 24 Aug 2005 09:15:26 GMT]]></title><description><![CDATA[<p>Hmm, gut zu wissen. Habs aber auch noch nie benutzt :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/857371</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/857371</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Wed, 24 Aug 2005 09:15:26 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Wed, 24 Aug 2005 09:48:15 GMT]]></title><description><![CDATA[<p>FireFlow: Wenn du im Destruktor eine Funktion aufrufst, kann es dort auftreten:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;exception&gt;
using namespace std;

class Foo
{
public:
    void finalize()
    {
    	if(uncaught_exception())
            cout &lt;&lt; &quot;uncaught exception&quot;;
    }

    ~Foo()
    {
    	finalize();

    	// do other things
    }
};

int main()
{
	try
	{
		Foo foo;
		throw 1;
	}
	catch(...)
	{
	}
}
</code></pre>
<p>Oder wenn du im Destruktor ein Objekt erstellst, kann es im Konstruktor auftreten:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;exception&gt;
using namespace std;

class Bar
{
public:
    Bar()
    {
    	if(uncaught_exception())
            cout &lt;&lt; &quot;uncaught exception&quot;;
    }
};

class Foo
{
public:    
    ~Foo()
    {
    	Bar bar;

    	// do other things
    }
};

int main()
{
	try
	{
		Foo foo;
		throw 1;
	}
	catch(...)
	{
	}
}
</code></pre>
<p>Aber grundsätzlich läufts über den Destruktor.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/857411</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/857411</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Wed, 24 Aug 2005 09:48:15 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 29 Aug 2005 08:25:27 GMT]]></title><description><![CDATA[<p>Hallo @all,</p>
<p>sorry, wenn ich diesen Beitrag jetzt wiederrechtlich okkupiere, aber es passt einfach zu gut zum Thema.<br />
Ich habe mal ein bisschen mit exception specs rumgespielt. Ich hätte eigentlich gedacht, das der Compiler bei folgendem Code meckert:</p>
<pre><code>void some_func() throw( exception )
{
    throw exception ( &quot;myExcept&quot; );
}

void MyAlloc(void) throw()
{
    some_func();
}
</code></pre>
<p>Ich hätte erwartet, das es zumindest ein warning giebt, da some_func ja wirft und das die spec von MyAlloc als Nothrow verletzt.<br />
Nach diesem Artikel : <a href="http://www.gotw.ca/publications/mill22.htm" rel="nofollow">http://www.gotw.ca/publications/mill22.htm</a> :</p>
<blockquote>
<p>Never write an exception specification.</p>
</blockquote>
<p>Eigentlich schade, weil ich es schon ganz schön finden würde, das vom Compiler zumindest teilweise checken zu lassen, ob ein exception - system konsistent ist. Außerdem müßte ich ja auch immer auf unexpected testen, wenn ich es dennoch benutze, weil ja alle compiler (zumindest VC, und g++) das komplett ignorieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/860469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/860469</guid><dc:creator><![CDATA[TheBigW]]></dc:creator><pubDate>Mon, 29 Aug 2005 08:25:27 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 29 Aug 2005 08:33:03 GMT]]></title><description><![CDATA[<p>TheBigW schrieb:</p>
<blockquote>
<p>Eigentlich schade, weil ich es schon ganz schön finden würde, das vom Compiler zumindest teilweise checken zu lassen, ob ein exception - system konsistent ist.</p>
</blockquote>
<p>Das geht aus 2 Gründen nicht. Erstens gibt es eine Menge Legacy-Code, der keine Exception-Spezifikationen enthält, obwohl er Exceptions wirft. Und zweitens kannst du bei Templates nicht wissen, welche Exceptions fliegen, da das Template-Argument beliebige Exceptions werfen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/860475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/860475</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Mon, 29 Aug 2005 08:33:03 GMT</pubDate></item><item><title><![CDATA[Reply to Checked Exceptions on Mon, 29 Aug 2005 09:06:48 GMT]]></title><description><![CDATA[<p>Das ist mir schon klar, aber das wie bei meinem Beispiel eindeutige Verletzungen nicht angezeigt werden ist schon schade.<br />
Meine eigentliche Frage hab ich dann wohl etwas unsauber formuliert : inwieweit ist dann die Verwendung von exception specifications sinnvoll : sie werden selbst in selbst geschriebenm Code nicht ausgewertet (Ich unterstelle mal, das man es konsequent umgesetzt hat) und ich muß mich mit obendrein damit herumschlagen, den Fall zu behandeln, das meine Spezifikation verletzt wird und bad_exception behandeln.<br />
Es wäre also wirklich sinnvoller die spec wegzulassen und in die Dokumentation zu verschieben.</p>
<blockquote>
<p>Erstens gibt es eine Menge Legacy-Code, der keine Exception-Spezifikationen enthält, obwohl er Exceptions wirft</p>
</blockquote>
<p>Na gut, der Fall wäre, das dieser code alles werfen kann. Das ist doch aber kein Begründung, warum man es im eigenen Code nicht wirklich verwenden kann.</p>
<blockquote>
<p>Und zweitens kannst du bei Templates nicht wissen, welche Exceptions fliegen, da das Template-Argument beliebige Exceptions werfen kann</p>
</blockquote>
<p>richtig, aber wenn ich eine template funktion habe, die als Nothrow (throw()) deklariert ist, dann giebt es halt einen Fehler wenn ein Template Argument verwendet wird, was eine andere spec hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/860497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/860497</guid><dc:creator><![CDATA[TheBigW]]></dc:creator><pubDate>Mon, 29 Aug 2005 09:06:48 GMT</pubDate></item></channel></rss>