This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: problem with fprintf and OpenMP
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Siegmar Gross <Siegmar dot Gross at informatik dot hs-fulda dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 15 May 2014 10:17:35 +0200
- Subject: Re: problem with fprintf and OpenMP
- Authentication-results: sourceware.org; auth=none
- References: <201405150601 dot s4F61DKf015468 at tyr dot informatik dot hs-fulda dot de>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, May 15, 2014 at 08:01:13AM +0200, Siegmar Gross wrote:
> I'm using gcc-4.9.0 and have a problem with the following program.
> I have reported the problem allready on gcc-help some days ago,
> but didn't get any replies. Perhaps somebody in this list knows,
> if the behaviour is intended.
Yes, this is what OpenMP standard requires.
> #include <stdio.h>
> #include <stdlib.h>
> #include <omp.h>
>
> int main (void)
> {
> #pragma omp parallel default (none)
> fprintf (stderr, "Hello!\n");
> return EXIT_SUCCESS;
> }
>
>
> I can solve the problem if I add "shared(__iob)" to "#pragma",
> but then the program isn't portable any longer.
Or don't use default (none), or don't use stderr directly in the
default(none) parallel region (use a temporary variable, call
a function that implicitly uses stderr, etc.).
> In my opinion the compiler knows that I use OpenMP and that
> I use "default(none)" so that it can automatically add all
> necessary internal variables to the "shared clause" or that
Please define what is internal variable. __iob is for the compiler
not an internal variable of any kind, stderr is a macro like any other.
Note that e.g. on Linux stderr is a macro and a variable
(#define stderr stderr), treating in that case stderr as an internal
variable would be really weird.
Jakub