Re: Static global - bug? (Re: Two valgrind warningsinOpenSSL-possible bug???)

2008-01-29 Thread Brad House
void foo(void) { static int *my_errno=NULL; if(my_errno==NULL) my_errno=errno; // code that uses 'my_errno' as if it were 'errno' } No, this is not legal code under the POSIX standard at all. Since this code is single-threaded only, what POSIX standard are you talking about? The pthreads

RE: Static global - bug? (Re: Two valgrind warningsinOpenSSL-possible bug???)

2008-01-29 Thread David Schwartz
void foo(void) { static int *my_errno=NULL; if(my_errno==NULL) my_errno=errno; // code that uses 'my_errno' as if it were 'errno' } No, this is not legal code under the POSIX standard at all. Since this code is single-threaded only, what POSIX standard are you talking about? The

RE: Static global - bug? (Re: Two valgrind warningsinOpenSSL-possible bug???)

2008-01-29 Thread David Schwartz
Well, I'm late to this discussion, but it would seem to me that quite a few things are wrong with that ... First, my_errno=errno; might be more appropriate, after all, you need to reference the address of errno, not the current value, right? But that would also assume errno is declared as

RE: Static global - bug? (Re: Two valgrind warningsinOpenSSL-possible bug???)

2008-01-29 Thread David Schwartz
The answer is that if you're compiled single-threaded, it's perfectly legal. If you're multi-threaded, it's not. I guess by legal you mean that it has defined behaviour. Yes, that's correct. Both the C99 standard and SUS have this nice warning in it. In C99: errno