variable 'new_value' is used uninitialized whenever 'if' condition is false

Jonathan,
      Are the warnings of the form...

/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2035:1:
warning: variable 'new_value' is used uninitialized whenever 'if'
condition is false
      [-Wsometimes-uninitialized]
MIN_MAX_COMPXCHG_CPT( fixed1, max_cpt, char, 8, <,
KMP_ARCH_X86 ) // __kmpc_atomic_fixed1_max_cpt
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2028:9:
note: expanded from macro 'MIN_MAX_COMPXCHG_CPT'
        GOMP_MIN_MAX_CRITSECT_CPT(OP,GOMP_FLAG) \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1984:9:
note: expanded from macro 'GOMP_MIN_MAX_CRITSECT_CPT'
        MIN_MAX_CRITSECT_CPT( OP, 0 ); \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1968:10:
note: expanded from macro 'MIN_MAX_CRITSECT_CPT'
    if ( *lhs OP rhs ) { /* still need actions? */ \
         ^~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2035:1:
note: uninitialized use occurs here
MIN_MAX_COMPXCHG_CPT( fixed1, max_cpt, char, 8, <,
KMP_ARCH_X86 ) // __kmpc_atomic_fixed1_max_cpt
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2028:9:
note: expanded from macro 'MIN_MAX_COMPXCHG_CPT'
        GOMP_MIN_MAX_CRITSECT_CPT(OP,GOMP_FLAG) \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1984:9:
note: expanded from macro 'GOMP_MIN_MAX_CRITSECT_CPT'
        MIN_MAX_CRITSECT_CPT( OP, 0 ); \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1977:12:
note: expanded from macro 'MIN_MAX_CRITSECT_CPT'
    return new_value; \
           ^~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2035:1:
note: remove the 'if' if its condition is always true
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2028:9:
note: expanded from macro 'MIN_MAX_COMPXCHG_CPT'
        GOMP_MIN_MAX_CRITSECT_CPT(OP,GOMP_FLAG) \
        ^
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1984:9:
note: expanded from macro 'GOMP_MIN_MAX_CRITSECT_CPT'
        MIN_MAX_CRITSECT_CPT( OP, 0 ); \
        ^
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1968:5:
note: expanded from macro 'MIN_MAX_CRITSECT_CPT'
    if ( *lhs OP rhs ) { /* still need actions? */ \
    ^
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2035:41:
note: variable 'new_value' is declared here
MIN_MAX_COMPXCHG_CPT( fixed1, max_cpt, char, 8, <,
KMP_ARCH_X86 ) // __kmpc_atomic_fixed1_max_cpt
                                        ^
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2026:5:
note: expanded from macro 'MIN_MAX_COMPXCHG_CPT'
    TYPE new_value, old_value; \
    ^

significant? These seem to be generated from the macro definition...

#define MIN_MAX_COMPXCHG_CPT(TYPE_ID,OP_ID,TYPE,BITS,OP,GOMP_FLAG) \
ATOMIC_BEGIN_CPT(TYPE_ID,OP_ID,TYPE,TYPE) \
    TYPE new_value, old_value; \
    if ( *lhs OP rhs ) { \
        GOMP_MIN_MAX_CRITSECT_CPT(OP,GOMP_FLAG) \
        MIN_MAX_CMPXCHG_CPT(TYPE,BITS,OP) \
    } \
    return *lhs; \
}

        Jack

What compiler version is producing all these warnings? Is it clang 3.7?

-- Johnny

Jonathan,
      All of my builds on x86_64-apple-darwin14 are using the system
clang compilers from Xcode 6.3.2...

% clang -v
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix

I'll try a rebuild with LLVM clang 3.6.0 and see if there is any
differences in the warnings produced.
         Jack

Jonathan,
      I also see these same errors when building current openmp using
the LLVM clang 3.6.0 compilers instead of the system compilers on
x86_64-apple-darwin14.
                             Jack

/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2037:1:
warning: variable 'new_value' is used uninitialized whenever 'if'
      condition is false [-Wsometimes-uninitialized]
MIN_MAX_COMPXCHG_CPT( fixed2, max_cpt, short, 16, <,
KMP_ARCH_X86 ) // __kmpc_atomic_fixed2_max_cpt
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2028:9:
note: expanded from macro 'MIN_MAX_COMPXCHG_CPT'
        GOMP_MIN_MAX_CRITSECT_CPT(OP,GOMP_FLAG) \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1984:9:
note: expanded from macro 'GOMP_MIN_MAX_CRITSECT_CPT'
        MIN_MAX_CRITSECT_CPT( OP, 0 ); \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1968:10:
note: expanded from macro 'MIN_MAX_CRITSECT_CPT'
    if ( *lhs OP rhs ) { /* still need actions? */ \
         ^~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2037:1:
note: uninitialized use occurs here
MIN_MAX_COMPXCHG_CPT( fixed2, max_cpt, short, 16, <,
KMP_ARCH_X86 ) // __kmpc_atomic_fixed2_max_cpt
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2028:9:
note: expanded from macro 'MIN_MAX_COMPXCHG_CPT'
        GOMP_MIN_MAX_CRITSECT_CPT(OP,GOMP_FLAG) \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1984:9:
note: expanded from macro 'GOMP_MIN_MAX_CRITSECT_CPT'
        MIN_MAX_CRITSECT_CPT( OP, 0 ); \
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1977:12:
note: expanded from macro 'MIN_MAX_CRITSECT_CPT'
    return new_value; \
           ^~~~~~~~~
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2037:1:
note: remove the 'if' if its condition is always true
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2028:9:
note: expanded from macro 'MIN_MAX_COMPXCHG_CPT'
        GOMP_MIN_MAX_CRITSECT_CPT(OP,GOMP_FLAG) \
        ^
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1984:9:
note: expanded from macro 'GOMP_MIN_MAX_CRITSECT_CPT'
        MIN_MAX_CRITSECT_CPT( OP, 0 ); \
        ^
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:1968:5:
note: expanded from macro 'MIN_MAX_CRITSECT_CPT'
    if ( *lhs OP rhs ) { /* still need actions? */ \
    ^
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2037:41:
note: variable 'new_value' is declared here
MIN_MAX_COMPXCHG_CPT( fixed2, max_cpt, short, 16, <,
KMP_ARCH_X86 ) // __kmpc_atomic_fixed2_max_cpt
                                        ^
/sw/src/fink.build/llvm37-3.7.0-100/llvm-3.7.0.src/projects/openmp/runtime/src/kmp_atomic.c:2026:5:
note: expanded from macro 'MIN_MAX_COMPXCHG_CPT'
    TYPE new_value, old_value; \
    ^

This could be a real problem, we need to investigate further.

Thanks,
Andrey