Fix string buffer size for OpenMP proc-bind 'primary'.
Corrected string buffer size in libgomp to properly handle the 'primary' proc-bind value, resolving a C++ compilation error.
This commit fixes a bug in libgomp’s environment variable parsing for OpenMP 5.1’s ‘proc-bind’ directive. The previous code did not allocate sufficient space for the string literal ‘primary’, causing a compilation error with C++ when using ‘-Wc++-compat’. The fix increases the size of the ‘proc_bind_kinds::name’ array to accommodate the null terminator for ‘primary’, ensuring correct behavior.
In Details
The 'proc_bind_kinds' array in libgomp's env.c stores string representations of thread affinity policies. The addition of 'primary' in OpenMP 5.1 required a larger buffer in the 'name' field to hold the string and its null terminator. The previous commit that added 'primary' support failed to resize this buffer, leading to a C++ compatibility warning and error when compiling libgomp with strict C++ standards, as the initializer string exceeded the available space. This patch corrects the size.
- proc-bind
- An OpenMP clause that specifies how threads in a team are assigned to the places of a device. 'primary' is a new value introduced in OpenMP 5.1.
- OpenMP
- An API that supports multi-platform shared-memory parallel programming.