https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69389
Bug ID: 69389 Summary: bit field incompatible with OpenMP atomic update Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: weeks at iastate dot edu Target Milestone: --- gcc 5.2.0 cannot utilize bit fields within an OpenMP atomic update. Consider the following code (atomic_bitwise_or.c): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include <stdio.h> struct BGZF { unsigned errcode:16, is_write:2, is_be:2; }; int main(void) { struct BGZF A = {0}; #pragma omp parallel #pragma omp master #pragma omp atomic update A.errcode |= 1; if (A.errcode != 1) { printf("failed\n"); return 1; } else { printf("success\n"); return 0; } } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When compiled without OpenMP, it produces the expected result: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $ gcc atomic_bitwise_or.c $ ./a.out success ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ However, it fails to compile when OpenMP is enabled: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $ gcc -fopenmp atomic_bitwise_or.c atomic_bitwise_or.c: In function 'main': atomic_bitwise_or.c:13:4: error: cannot take address of bit-field 'errcode' A.errcode |= 1; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcc version info: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $ gcc -v Using built-in specs. COLLECT_GCC=/opt/gcc/5.2.0/bin/../snos/bin/gcc COLLECT_LTO_WRAPPER=/opt/gcc/5.2.0/snos/libexec/gcc/x86_64-suse-linux/5.2.0/lto-wrapper Target: x86_64-suse-linux Configured with: ../cray-gcc-5.2.0/configure --prefix=/opt/gcc/5.2.0/snos --disable-nls --libdir=/opt/gcc/5.2.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/5.2.0/snos/include/g++ --with-slibdir=/opt/gcc/5.2.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog Thread model: posix gcc version 5.2.0 20150716 (Cray Inc.) (GCC) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~