STEllAR-GROUP / hpx

The C++ Standard Library for Parallelism and Concurrency

Home Page:https://hpx.stellar-group.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning: type attributes ignored after type is already defined

diehlpk opened this issue · comments

Expected Behavior

No warning should appear.

Actual Behavior

In file included from /usr/local/hpx-corot/include/hpx/parcelset_base/policies/message_handler.hpp:14,
                 from /usr/local/hpx-corot/include/hpx/parcelset_base/parcel_interface.hpp:24,
                 from /usr/local/hpx-corot/include/hpx/agas_base/primary_namespace.hpp:17,
                 from /usr/local/hpx-corot/include/hpx/async_colocated/async_colocated.hpp:13,
                 from /usr/local/hpx-corot/include/hpx/distribution_policies/colocating_distribution_policy.hpp:17,
                 from /usr/local/hpx-corot/include/hpx/parallel/segmented_algorithms/detail/dispatch.hpp:16,
                 from /usr/local/hpx-corot/include/hpx/parallel/segmented_algorithms/adjacent_difference.hpp:17,
                 from /usr/local/hpx-corot/include/hpx/parallel/segmented_algorithm.hpp:12,
                 from /usr/local/hpx-corot/include/hpx/algorithm.hpp:10,
                 from /usr/local/hpx-corot/include/hpx/hpx.hpp:10,
                 from __code__.cpp:2:
/usr/local/hpx-corot/include/hpx/parcelset_base/parcelset_base_fwd.hpp:17:22: warning: type attributes ignored after type is already defined [-Wattributes]
   17 |     class HPX_EXPORT locality;
      | 

Specifications

... Please describe your environment

  • HPX Version: HPX 1.8.1
  • Platform (compiler, OS): gcc

Hello, @diehlpk.
Since no one is currently assigned, I would like to take up this issue.
Could you please provide me with a minimum example to reproduce it, and any other changes that you may have performed? My compiler does not report this, even after giving specific flags for reporting attribute errors. Thank you in advance!

Hello, @diehlpk. Since no one is currently assigned, I would like to take up this issue. Could you please provide me with a minimum example to reproduce it, and any other changes that you may have performed? My compiler does not report this, even after giving specific flags for reporting attribute errors. Thank you in advance!

Please go ahead. There is no need to ask for having a task 'assigned' to you. Just do it.

For the problem in question: this warning happens if the compiler first sees a type declared without an attribute, but later the same type is being declared/defined using an attribute, e.g.:

struct A;
struct HPX_EXPORT A {...};

The way to resolve this problem is to move the attribute to the first declaration and make sure that the compiler always sees this declaration before the later definition/declaration.

Hi @hkaiser. I was looking through this issue and I also couldn't reproduce it.

I'm not sure if I'm trying to reproduce it on the right place. I'm testing on branch 1.8.1 --that has the latest tag for the v1.8.1 release-- and running the same build steps found in the documentation.

After running cmake --build . --target install I found another error:

/hpx/libs/core/iterator_support/include/hpx/iterator_support/counting_iterator.hpp:58:53: error: ‘intmax_t’ is not a member of ‘std’; did you mean ‘intmax_t’?
   58 |                     (sizeof(Integer) >= sizeof(std::intmax_t)),
      |                                                     ^~~~~~~~

This error happens because #include<cstdint> is missing in hpx/libs/core/iterator_support/include/hpx/iterator_support/counting_iterator.hpp and std::intmax_t is being used.

It seems that this error is already fixed for version 1.9.x. Is there another branch for v1.8.1 that already solved those issues? I tested other branches like 1.8.1-rc2 and it has the same error.

I would love to subimit a PR for both issues.

Hello all! This might be a novice question, but is it at all possible that the initial warning is not being reported because the function defined in the file hasn’t been used yet?

Hi @hkaiser. I was looking through this issue and I also couldn't reproduce it.

I'm not sure if I'm trying to reproduce it on the right place. I'm testing on branch 1.8.1 --that has the latest tag for the v1.8.1 release-- and running the same build steps found in the documentation.

After running cmake --build . --target install I found another error:

/hpx/libs/core/iterator_support/include/hpx/iterator_support/counting_iterator.hpp:58:53: error: ‘intmax_t’ is not a member of ‘std’; did you mean ‘intmax_t’?
   58 |                     (sizeof(Integer) >= sizeof(std::intmax_t)),
      |                                                     ^~~~~~~~

This error happens because #include<cstdint> is missing in hpx/libs/core/iterator_support/include/hpx/iterator_support/counting_iterator.hpp and std::intmax_t is being used.

It seems that this error is already fixed for version 1.9.x. Is there another branch for v1.8.1 that already solved those issues? I tested other branches like 1.8.1-rc2 and it has the same error.

I would love to subimit a PR for both issues.

Please test against the master branch as we will not patch up the old V1.8.1 release.

Hello all! This might be a novice question, but is it at all possible that the initial warning is not being reported because the function defined in the file hasn’t been used yet?

Could you be more specific, please? I'm not sure I understand what you're trying to say.

Please test against the master branch as we will not patch up the old V1.8.1 release.

I think maybe this issue is already solved. I tested it against master and enabled -Wattributes, but couldn't find it.

Also, I found some other warnings from -Wattributes that might be interesting to take a look:

/repos/hpx/libs/core/config/src/version.cpp:16:50: warning: ‘visibility’ attribute ignored [-Wattributes]
   16 |     HPX_CORE_EXPORT char const HPX_CHECK_VERSION[] =
      |                                                  ^
/repos/hpx/libs/core/config/src/version.cpp:18:56: warning: ‘visibility’ attribute ignored [-Wattributes]
   18 |     HPX_CORE_EXPORT char const HPX_CHECK_BOOST_VERSION[] =
      |                                                        ^
[546/803] Building CXX object components/containers/partitioned_vector/CMakeFiles/partitioned_vector_component.dir/src/partitioned_vector_component_std_string.cpp.o
/repos/hpx/components/containers/partitioned_vector/src/partitioned_vector_component_std_string.cpp:31:18: warning: type attributes ignored after type is already defined [-Wattributes]
   31 |     hpx::server::partitioned_vector<std::string, std::vector<std::string>>;
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[547/803] Building CXX object components/containers/partitioned_vector/CMakeFiles/partitioned_vector_component.dir/src/partitioned_vector_component_double.cpp.o
/repos/hpx/components/containers/partitioned_vector/src/partitioned_vector_component_double.cpp:28:18: warning: type attributes ignored after type is already defined [-Wattributes]
   28 |     hpx::server::partitioned_vector<double, std::vector<double>>;
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[556/803] Building CXX object components/containers/partitioned_vector/CMakeFiles/partitioned_vector_component.dir/src/partitioned_vector_component_int.cpp.o
/repos/hpx/components/containers/partitioned_vector/src/partitioned_vector_component_int.cpp:30:18: warning: type attributes ignored after type is already defined [-Wattributes]
   30 |     hpx::server::partitioned_vector<int, std::vector<int>>;
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/repos/hpx/components/containers/partitioned_vector/src/partitioned_vector_component_int.cpp:43:18: warning: type attributes ignored after type is already defined [-Wattributes]
   43 |     hpx::server::partitioned_vector<long long, std::vector<long long>>;
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

They seem to be around for a wile. I don't know if they are supposed to be fixed or not.

Please test against the master branch as we will not patch up the old V1.8.1 release.

I think maybe this issue is already solved. I tested it against master and enabled -Wattributes, but couldn't find it.

Also, I found some other warnings from -Wattributes that might be interesting to take a look:

/repos/hpx/libs/core/config/src/version.cpp:16:50: warning: ‘visibility’ attribute ignored [-Wattributes]
   16 |     HPX_CORE_EXPORT char const HPX_CHECK_VERSION[] =
      |                                                  ^
/repos/hpx/libs/core/config/src/version.cpp:18:56: warning: ‘visibility’ attribute ignored [-Wattributes]
   18 |     HPX_CORE_EXPORT char const HPX_CHECK_BOOST_VERSION[] =
      |                                                        ^
[546/803] Building CXX object components/containers/partitioned_vector/CMakeFiles/partitioned_vector_component.dir/src/partitioned_vector_component_std_string.cpp.o
/repos/hpx/components/containers/partitioned_vector/src/partitioned_vector_component_std_string.cpp:31:18: warning: type attributes ignored after type is already defined [-Wattributes]
   31 |     hpx::server::partitioned_vector<std::string, std::vector<std::string>>;
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[547/803] Building CXX object components/containers/partitioned_vector/CMakeFiles/partitioned_vector_component.dir/src/partitioned_vector_component_double.cpp.o
/repos/hpx/components/containers/partitioned_vector/src/partitioned_vector_component_double.cpp:28:18: warning: type attributes ignored after type is already defined [-Wattributes]
   28 |     hpx::server::partitioned_vector<double, std::vector<double>>;
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[556/803] Building CXX object components/containers/partitioned_vector/CMakeFiles/partitioned_vector_component.dir/src/partitioned_vector_component_int.cpp.o
/repos/hpx/components/containers/partitioned_vector/src/partitioned_vector_component_int.cpp:30:18: warning: type attributes ignored after type is already defined [-Wattributes]
   30 |     hpx::server::partitioned_vector<int, std::vector<int>>;
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/repos/hpx/components/containers/partitioned_vector/src/partitioned_vector_component_int.cpp:43:18: warning: type attributes ignored after type is already defined [-Wattributes]
   43 |     hpx::server::partitioned_vector<long long, std::vector<long long>>;
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

They seem to be around for a wile. I don't know if they are supposed to be fixed or not.

Yes, those should be fixed (suppressed). Thanks!