Page MenuHomePhabricator

[OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions

Authored by gtbercea on May 15 2019, 8:11 AM.

Diff Detail

rC Clang

Event Timeline

gtbercea created this revision.May 15 2019, 8:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2019, 8:11 AM
Hahnfeld added inline comments.

If I recall correctly, __cplusplus is not defined in C mode, so both GCC and Clang will issue a warning with -Wundef.

Maybe this can be solved with something similar to:

#ifdef __cplusplus
#define cpp_version __cplusplus
#define cpp_version 0

(to avoid repetition of #if defined(__cplusplus) && __cplusplus >= 201703L)

Missing defined(__cplusplus) to avoid warnings and we have to resolve the two new includes. Otherwise, this looks good. So, if you "fix" both go ahead and commit, if not, lets discuss.


I dislike defining the version and advice to repeating #if defined(__cplusplus) && __cplusplus >= 201703L)

24 ↗(On Diff #199613)

I ask this question again and again, do we need them now? Why?

tra added inline comments.May 15 2019, 9:43 AM

I agree with @jdoerfert.
If that's needed too often, we can move c++-only functions under one global #if defined(__cplusplus).


This is typically dealt with by defining and using a macro which would expand to noexcept or to nothing.
E.g. something like what libcxx does.

This should reduce the number of needed #if.

gtbercea updated this revision to Diff 199651.May 15 2019, 11:46 AM
  • Refactor.
gtbercea marked an inline comment as done.May 15 2019, 11:49 AM
gtbercea added inline comments.

@tra is this closer to what you want?

tra added a comment.May 15 2019, 12:12 PM



I think the change is useful for CUDA, too, but I'm OK keeping it OpenMP-specific for now. I can enable it for CUDA later.

jdoerfert requested changes to this revision.May 15 2019, 12:15 PM
jdoerfert added inline comments.
24 ↗(On Diff #199613)

Why did you add these includes?

This revision now requires changes to proceed.May 15 2019, 12:15 PM
gtbercea updated this revision to Diff 199662.May 15 2019, 12:44 PM
gtbercea marked an inline comment as done.
  • Remove included headers.
jdoerfert accepted this revision.May 15 2019, 12:49 PM
This revision is now accepted and ready to land.May 15 2019, 12:49 PM
This revision was automatically updated to reflect the committed changes.