ompi icon indicating copy to clipboard operation
ompi copied to clipboard

Replace alignment_of_long_double with C11 alignof

Open devreal opened this issue 1 year ago • 9 comments

This removes a static variable in a static function and uses C11 provides alignof instead to get a compile-time value.

Also fixes this compiler warning:

opal_copy_functions_heterogeneous.c:495:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
  495 | alignment_of_long_double() {
      | ^~~~~~~~~~~~~~~~~~~~~~~~

I'm not sure why alignof would not be portable, since it's part of the C11 standard. All C11 compilers I tried on godbolt worked as expected (and some exotic 32bit compiler versions seemed to indicate 8B alignment for long double, not 4). Asking the compiler for the alignment seems to be the safe and reasonable choice.

devreal avatar Jul 08 '24 14:07 devreal