https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88967

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
firstprivate is that each thread will have its own copy of the variable,
initialized from the original.
shared means there is just one copy.
E.g. if you take the address of the variable within the region, for
firstprivate each thread will have different, typically it will be a stack slot
in the outlined function, while for shared it will need to live either in the
structure used to pass data around, or worse address of that variable will be
passed in that structure.  While e.g. some recent versions of gcc try to
optimize
certain cases of shared into firstprivate, see e.g. PR68128 (or for
non-addressable non-reference const vars it was done even much earlier), that
is just an optimization not every compiler will do for you.

Reply via email to