hpx icon indicating copy to clipboard operation
hpx copied to clipboard

Warning: type attributes ignored after type is already defined

Open diehlpk opened this issue 2 years ago • 8 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

diehlpk avatar Dec 14 '23 19:12 diehlpk

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!

Komal0103 avatar Jan 14 '24 20:01 Komal0103

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.

hkaiser avatar Jan 14 '24 21:01 hkaiser

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.

andremralves avatar Feb 26 '24 20:02 andremralves

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?

Komal0103 avatar Feb 26 '24 20:02 Komal0103

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.

hkaiser avatar Feb 26 '24 21:02 hkaiser

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.

hkaiser avatar Feb 26 '24 21:02 hkaiser

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.

andremralves avatar Feb 27 '24 00:02 andremralves

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!

hkaiser avatar Feb 27 '24 12:02 hkaiser