Project

General

Profile

Feature #2248

Updated by Roland Schulz about 3 years ago

#2247 would have triggered a compiler warning in Clang if the SIMD function were labeled as <pre>[[nodiscard]]</pre> "[[nodiscard]]" (since clang 4) or <pre>__attribute__ ((pure))</pre> "__attribute__ ((pure))" (since at least 3.4).

Questions:
1) Is it worth labeling all SIMD functions/operators to avoid bugs like this in the future?
2) Is it better to label them as pure or nodiscard? Pro pure: could inform the compiler about more than the return value (Does that enable any new optimizations?). Pro nodiscard: non-gcc extension and could be used also for non-pure
3) Should we introduce a gmx_nodiscard/pure? Alternative is to directly use the nodiscard attribute [[nodiscard]] but then we need to "-Wno-attributes" for older compilers which don't have that attribute yet
4) Should the attribute be added to all implementations? Alternative would be to have a separate declaration for all function (which also would contain the doxygen) which has the attribute and have the implementations only have the definition.

Back