|
Boost : |
Subject: Re: [boost] Question for C++experts aboutexception allocationfailure
From: Adam Badura (abadura_at_[hidden])
Date: 2009-05-19 01:37:26
> Here's a perfectly legal, perfectly defined C++03 program in a single
> module with a single thread that has a runtime-determined number of
> exceptions:
>
> #include <iostream>
>
> void fun(int recursions);
>
> int main()
> {
> int n;
> std::cin >> n;
> fun(n);
> }
>
> void fun(int recursions) {
> try {
> throw 0;
> } catch(int) {
> fun(recursions - 1);
> }
> }
Actually you must use the exception object in the catch so that the
compiler cannot optimize it away. So this example is not correct. :)
Adam Badura
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk