lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Unit test for C99 round()


From: Greg Chicares
Subject: Re: [lmi] Unit test for C99 round()
Date: Thu, 05 Jun 2008 01:25:02 +0000
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

On 2008-06-04 13:18Z, Vadim Zeitlin wrote:
> On Wed, 04 Jun 2008 02:20:12 +0000 Greg Chicares <address@hidden> wrote:
> 
> GC> As far as I remember, no other unit-test target needs any product
> GC> files other than 'sample.*', which 'product_files$(EXEEXT)' can
> GC> create.
> 
>  Unfortunately I have a problem with 'product_files' too... It crashes with
> SIGABRT because of the following funny sequence of events:

[...yick...]

Of course, it's not so funny that you had to go to such
lengths to trace it. This is broken.

> The real problem is, of course, the same one already discussed in the
> "product editor patch" thread from February 2008 and the best, AFAICS,
> solution was proposed by Vaclav in
> 
>    http://lists.nongnu.org/archive/html/lmi/2008-02/msg00026.html
> 
> However nothing was ever done about it, maybe we should return to this
> discussion?

Yes. I had flagged that message for later study, with some
misguided hope that I'd be able to say something perceptive
about it during this lifetime, but it's time to acknowledge
that it's over my head and answer, however belatedly:

On 2008-02-11 18:40Z, Vaclav Slavik wrote:
|
| What do you think about it, should I [try to] do it like this?

Yes, please.

>  However in the meanwhile I really think that safely_show_message() should
> not throw, ever. Throwing is not safe as can be seen from the scenario
> above.

I agree. To report "I'd like to report a critical error, but
I find that I have no means of doing so" calls for a little
extra robustness.

Here's the present implementation:

void safely_show_message(char const* message)
{
    if(0 == safe_message_alert_function)
        {
        throw std::runtime_error
            ("No function defined for reporting a problem safely."
            );
        }
    safe_message_alert_function(message);
}

Here's a rough sketch of a solution:

     if(0 == safe_message_alert_function)
         {
-        throw std::runtime_error
+        safely_report_catastrophe
             ("No function defined for reporting a problem safely."
             );
         }

...with an implementation like...

void safely_report_catastrophe(char const* p)
{
#if defined LMI_POSIX
    fputs(p, stderr);
    fputs('\n', stderr);
    fflush(stderr);
#elif defined LMI_MSW
    ::MessageBox(...I forget the "safest" way...);
#else // Unknown platform.
#   error Unknown platform. Consider contributing support.
#endif // Unknown platform.
}

What do you think? If you want to review and critique it, and
perhaps fill in the msw implementation, then I can commit it;
or rewrite it completely if you like, and I'll review yours.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]