Re: VC++ 2005 beta1 fails with pthreads benchmark tests

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Doug Harrison [MVP]" wrote
> On Tue, 19 Apr 2005 15:34:05 +0200, um wrote:
>
> > The code is not broken. In your quote you have left out the
> > relevant part of the code.
> > It is not perror which sets errno (funny imagination, btw).
> > errno is set by sem_trywait(). The code is:
> >
> > assert((result = sem_trywait(&s)) == -1);
> > if ( result == -1 )
> > {
> > perror("thread: sem_trywait 1: expected error"); // No error
> > assert(errno == EAGAIN);
>
> David was correct in his reply to you. Absent documentation to the
> contrary, standard library functions are free to set errno to non-zero
> values. Thus, your assert is based on the faulty expectation that perror
> preserves errno (which you assume equals EAGAIN) or sets it to EAGAIN
> itself.

Please see my followup to his posting. Even after changing it
the error still remains.
And: how do you explain the fact that compilers other than VC++2005
don't generate any error, incl. MS VC++6 and GNU ?
FYI: there are 122 test programs in total. All tests are passed with
the other compilers (incl. VC++6), except that VC++2005 fails with 26 of them.
Any thoughts on what might be the reason for such behaviour
between VC++6 and VC++2005 ?

>In addition, you originally posted:
>
> void *
> thr(void * arg)
> {
> sem_t s;
> int result;
>
> assert(sem_init(&s, PTHREAD_PROCESS_PRIVATE, 0) == 0);
>
> assert((result = sem_trywait(&s)) == -1);
>
> if ( result == -1 )
>
> <snip>
>
> That's just wrong, because nothing initializes s and result when NDEBUG is
> defined, i.e. in a release build. You must never put code that is part of
> your program's logic in asserts. You need to rethink your error handling
> strategy.

Right, but: these are a set of standard test programs to be run only
in debug mode. They are compiled AND executed collectively via a make file.
They are not intended to be used otherwise. They test whether
the library does function as expected on the given platform.
They are part of the pthreads distribution, not mine.



.



Relevant Pages

  • Re: VC++ 2005 beta1 fails with pthreads benchmark tests
    ... > It is not perror which sets errno ... your assert is based on the faulty expectation that perror ... preserves errno (which you assume equals EAGAIN) or sets it to EAGAIN ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Including test "main" programs in modules?
    ... David Simpson wrote: ... test programs for each module. ... I believe inherited by most current compilers ... At least gfortran, g95, and ifort have it. ...
    (comp.lang.fortran)
  • Re: GNU Fortran 95: Opinions?
    ... > F90/95 compilers, for use in the test suite. ... I've got plenty of that. ... that the codes they generate are test programs that should yield errors ...
    (comp.lang.fortran)