Re: [Lapackpp-devel] error handling
Status: Beta
Brought to you by:
cstim
|
From: Christian S. <sti...@tu...> - 2006-11-21 13:44:41
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dominik Wagenfuehr schrieb:
> BTW: Have you thought about a better error handling? I think a library
> should never ever break a program. But your assertion does nothing else.
> The program quits without any message. I use Lapack++ in a GUI so I only
> see an output if I create console test case and try to reproduce the
> crash. Anyway: A backend should never crash a frontend.
Yes and no. For "normal" error events that can occur during runtime
("file not found" or similar) this is perfectly true. However, the
assertions in lapackpp are intended to check for *programming* errors.
The header file documentation clearly says (well, it *should* say) that
for certain operations, certain conditions have to be fulfilled. E.g.,
the matrix dimensions of Blas_Mat_Mat_Mult must fit to each other. This
is a condition which the application can easily check *before* it calls
these functions - and for this reason lapackpp can rely upon these
conditions being fulfilled. That's the meaning of such an assertion.
If those conditions are not met, then most probably the application
programmer just made a programming error. Having some exceptions instead
of assertions IMHO don't change this much - in any case a user cannot do
anything about this failed condition; the programmer must fix the
application anyway. Therefore I want to have these checks as easy as
possible, and simply writing assert(...) IMHO is the easiest way.
In principle each of these assertions should be mentioned in the
documentation, like "This function requires the following assertions to
be true: A.size(0) == bla bla bla". In practice, the assertion are a
very helpful tool to find out programming errors as early as possible.
As a rule of thumb I'd suggest in every (non-trivial) function, the
correct value range of the function arguments should be checked by
assertions.
Depending on your libc and the compile flags during compiling lapackpp,
a failed assertion should indeed print an error message including the
source code file name, line number, and the failed condition. If this
isn't the case, you should consider recompiling lapackpp with
- --enable-debug and/or CXXFLAGS="-g -O0" and so on.
Regards,
Christian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iQCVAwUBRWMCvGXAi+BfhivFAQLgsAP9ElQxrNBXVeYjNMCgGEphCy0kyDzRua85
Vt8Wf6spWEqzN+dR5/5oXlLBl8wQIX80Ydga2N+xkSp40jODxz52yq5UZJvsP6wu
ihq6kOmSlGOcwUhUNyofvEbZfzrypL0dCIEjiyRzPdF4PZ2j0jeNVz1o50lioUhP
CZ2/rddqX3E=
=tYvX
-----END PGP SIGNATURE-----
|