Post by Nickolay SamofatovPost by Mike Nordelland if all called functions
cannot throw they do not install exception handling
frame to unwind local objects and enforce exception
specification (MSVC doesn't enforce it anyway).
Introducing large differences in how the code behaves depending
on what compiler it's compiled with. This I don't like.
If our code behaves correctly, explicit declaration of exception
specification cannot make it behave incorrectly.
If adding any other exception specifications than "throw()", the code will
perform differently depending on what compiler is used.
Post by Nickolay SamofatovEngine is not ready to handle anything except std::exception.
... and all types inheriting std::exception. This includes *any* exception
in a reasonably standard C++ program.
Post by Nickolay SamofatovBTW, handling of generic std::exception descendants is not correct
now. User doesn't get any error message for such exceptions.
Could you please elaborate?
I'm aware the code currently doesn't even use the exception argument in its
catch clause, which is odd, but is instead currently modeled to use the
explicitly set error values. For an example, have a look at alice.cpp, line
618. There you should find EXIT(FINI_OK);, and a few lines down you'll find
"catch (const std::exception&)". The code never uses the exception thrown,
but it indeed gets the error value by means of the definition of the macro
EXIT.
It's by no means an optimal design, but I'd say it's still way better than
the previous setjmp/longjmp mess. It was also the path of least resistance
(the minimum of work for the maximum of effect) when doing the conversion.
If you look at the definition of e.g. Firebird::status_exception it's
already got in place the needed functionality (the value() member function)
to "do the right thing", why it's just to "dig in" and start doing the
exception catching even better. :-)
Post by Nickolay SamofatovPost by Mike NordellNo. You cannot specify exception clause in "C" linkage in some
compilers, but MSVC6 always assumes that such functions can
throw exceptions.
/EHc takes care of that.
Yes, but this switch is only for MSVC7+. ;)
May I suggest a piece of documentation, or maybe even just starting the VC6
compiler from command line with argument "/?" ? :->
This switch has been present since at least VC6 without service packs (about
half a decade by now). What was added in VC7 was the [+-] postfix.
Post by Nickolay SamofatovPost by Mike Nordell(as our "C" functions do throw exceptions).
That was what I was afraid of, and something that must be fixed.
If planning to add (at least "throw()") ES as functions are visited,
it would be wise to at the same time move those functions from
C to C++ linkage.
Yes, this needs to be done. But I do not have plans to do it.
Then it seems you're not going to add even "throw()" ES after all for those
functions, right?
Post by Nickolay SamofatovI'm trying to fix only parts of code that are releated to my current
tasks (otherwise they will never be finished).
I can appreciate that, but if that includes adding "throw()" ES to
functions, and those functions are currently declared extern "C",
surely they must be modified to have C++ linkage.
My personal opinion is that we have more than enough language violations in
the code and should instead work towards decreasing, not increasing their
count. But that's just me...
Post by Nickolay Samofatovthrow() specification is beneficial for compilers that support it.
Look at public headers for widely used modern "C"-language libraries.
Will not. "Modern" C implies C99 - something C++ couldn't care less about.
Post by Nickolay Samofatovextern "C" {
void some_function() NOTHROW_SPEC;
}
Speak about language violations. This can't be anything but gcc-isms, can
it? Could you provide a pointer to one single (publicly available) library
using such language violations?
Post by Nickolay SamofatovI also suppose that we should add "throw()" to functions that are
not expected to throw exceptions.
Not sure about that. I'm all for adding it to (again, only C++) functions
that are expected to not throw exceptions. I'm however not so sure it should
be added for functions that are not expected to throw exceptions.
Post by Nickolay SamofatovI also think that we should move all
functions except the ones from public API out of extern "C".
I most certainly agree. Putting them in extern "C" was a Q&D way to be able
to change the code incrementally from C->C++. Since that is now complete,
extern "C" for those functions (and types) has served its purpose and should
in the end be all but a memory.
Post by Nickolay SamofatovAnd add NOTHROW_SPEC to functions from public API.
No! There is now way a C function can legally throw a C++ exception. It
makes no sense to have ES for C functions. It's actually explicitly
sensless. C++ compilers that can't (be made to) understand this are IMNSHO
broken.
<snip>
Post by Nickolay SamofatovBut the code of engine is generally signal-safe at least when
built with GCC on Linux x86.
So if using Linux x86 and compiling the code with GCC it generally works,
but any other (POSIX-) platform or compiler might or might not work (at
all) - possibly thanks to the premeditated language violations? Maybe I'm
missing something here, but how could this be considered a Good Thing(tm)?
:-)
/Mike