Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPX does not compile with G++ version prior to 9.3. #6240

Open
JiakunYan opened this issue May 11, 2023 · 5 comments
Open

HPX does not compile with G++ version prior to 9.3. #6240

JiakunYan opened this issue May 11, 2023 · 5 comments

Comments

@JiakunYan
Copy link
Contributor

JiakunYan commented May 11, 2023

Expected Behavior

Compile successfully for any compilers supporting c++17.

Actual Behavior

G++ 8.5 gave me an error error: expected unqualified-id before '[' token

Steps to Reproduce the Problem

Just compile it with G++ 8.5.

Specifications

  • HPX Version: the master branch ad3ac76e159692355d4715f8b275c0a062b859af
  • Platform (compiler, OS): G++ 8.5. This should apply to any version prior to g++9.3.

Comment

This is not a fault of HPX, but G++, but this ticket can at least serve as an explanation for future users encountering this error. This is caused by a bug in G++ prior to 9.3. G++ doesn't parse correctly the [[maybe_unused]] attribute for the constructor's first argument. However, HPX uses it in libs/core/executors/include/hpx/executors/service_executors.hpp line 49.

explicit service_executor([[maybe_unused]] hpx::util::io_service_pool* pool) noexcept

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81429.

@hkaiser
Copy link
Member

hkaiser commented May 11, 2023

We can make this attribute conditional, though.

@Johan511
Copy link
Contributor

Do we look into replacing maybe_unused with a #define, possibly something like HPX_UNUSED which falls back to attribute((unused)) for older GCC versions?

@hkaiser
Copy link
Member

hkaiser commented May 24, 2023

We do have HPX_UNUSED, however its use is different from [[maybe_unused]]. So instead of writing:

void foo([[maybe_unused]] int bar) {}

one would have to write:

void foo(int bar) { HPX_UNUSED(bar); }

We should make those changes only singular places when necessary, though.

@Johan511
Copy link
Contributor

So everywhere we use [[maybe_unused]] should be replaced with HPX_UNUSED

or we could have another #define for [[maybe_unused]] which falls back to __attribute((unused))

Any comments on what you believe is better?

@hkaiser
Copy link
Member

hkaiser commented May 24, 2023

So everywhere we use [[maybe_unused]] should be replaced with HPX_UNUSED

No! Everywhere possible where we currently use HPX_UNUSED we should use [[maybe_unused]] instead.

or we could have another #define for [[maybe_unused]] which falls back to __attribute((unused))

How many spots would that be used in? If it's just a handful, I think it's not worth the trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants