While building the cpp_thread_test included in the OpenBLAS repository, we encountered a compilation error.
The issue appears to have been introduced by the following merge commit:
commit 8f0b0333ba0e1b8e185017112c2e760f5e616fce
Merge pull request #5876 from kumaraditya303/openmp
fix thread safety and data races of openmp backend
The cpp_thread_test/Makefile compiles dgemv_thread_safety.cpp using $(CXX) with -std=c++11. In our environment, CXX is set to g++, so the file is compiled with g++ -std=c++11.
During compilation, dgemv_thread_safety.cpp includes common.h, and the following code produces an error:
atomic_store((volatile _Atomic BLASULONG *)address, (BLASULONG)0);
The error messages are as follows:
../common.h:595:26: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
595 | atomic_store((volatile _Atomic BLASULONG *)address, (BLASULONG)0);
| ^~~~~~~
../common.h:595:17: error: expected primary-expression before ‘volatile’
595 | atomic_store((volatile _Atomic BLASULONG *)address, (BLASULONG)0);
| ^~~~~~~~
../common.h:595:17: error: expected ‘)’ before ‘volatile’
595 | atomic_store((volatile _Atomic BLASULONG *)address, (BLASULONG)0);
| ~^~~~~~~~
make: *** [Makefile:7: dgemv_tester] Error 1
During the OpenBLAS configuration step, the C compiler specified by CC is used to check for C11 atomic support. If the check succeeds, HAVE_C11 is defined in the generated config.h.
Because common.h includes this config.h, HAVE_C11 remains defined when cpp_thread_test is later compiled as C++11. This causes common.h to select the C11 atomic implementation, which contains the following cast:
(volatile _Atomic BLASULONG *)address
Although _Atomic is valid in C11, this type syntax is not valid in C++11. Therefore, the C++ compiler cannot parse the cast as a valid type, and the cpp_thread_test build fails.
We would appreciate the maintainers' thoughts on this issue and whether a fix could be considered to preserve compatibility with C++11 compilers.
If additional build logs, compiler information, or the generated config.h would be helpful, we would be happy to provide them.
While building the cpp_thread_test included in the OpenBLAS repository, we encountered a compilation error.
The issue appears to have been introduced by the following merge commit:
The cpp_thread_test/Makefile compiles dgemv_thread_safety.cpp using $(CXX) with -std=c++11. In our environment, CXX is set to g++, so the file is compiled with g++ -std=c++11.
During compilation, dgemv_thread_safety.cpp includes common.h, and the following code produces an error:
atomic_store((volatile _Atomic BLASULONG *)address, (BLASULONG)0);The error messages are as follows:
During the OpenBLAS configuration step, the C compiler specified by CC is used to check for C11 atomic support. If the check succeeds, HAVE_C11 is defined in the generated config.h.
Because common.h includes this config.h, HAVE_C11 remains defined when cpp_thread_test is later compiled as C++11. This causes common.h to select the C11 atomic implementation, which contains the following cast:
(volatile _Atomic BLASULONG *)addressAlthough _Atomic is valid in C11, this type syntax is not valid in C++11. Therefore, the C++ compiler cannot parse the cast as a valid type, and the cpp_thread_test build fails.
We would appreciate the maintainers' thoughts on this issue and whether a fix could be considered to preserve compatibility with C++11 compilers.
If additional build logs, compiler information, or the generated config.h would be helpful, we would be happy to provide them.