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

Compiling with GCC and -Wshadow flag produces a ton warnings #40

Open
schdub opened this issue Nov 20, 2024 · 0 comments · May be fixed by #41
Open

Compiling with GCC and -Wshadow flag produces a ton warnings #40

schdub opened this issue Nov 20, 2024 · 0 comments · May be fixed by #41

Comments

@schdub
Copy link

schdub commented Nov 20, 2024

Hi.

Simple code, like this

#include <poolstl/poolstl.hpp>
#include <vector>
#include <cassert>

int main() {
    std::vector<int> v(40 * 1024 * 1024, 0);
    v.front() = 100;
    v.back() = -1;
    std::sort(poolstl::par, v.begin(), v.end(), std::less());
    assert(v.front() < v.back());
}

Produced a bunch of warnings when comgiled using gcc and -Wshadow.

In file included from include/poolstl/execution:16,
                 from include/poolstl/poolstl.hpp:15,
                 from a.cpp:1:
include/poolstl/internal/utils.hpp: In constructor ‘poolstl::internal::getting_iter<Iterator>::getting_iter(Iterator)’:
include/poolstl/internal/utils.hpp:77:44: warning: declaration of ‘iter’ shadows a member of ‘poolstl::internal::getting_iter<Iterator>’ [-Wshadow]
   77 |             explicit getting_iter(Iterator iter) : iter(iter) {}
      |                                   ~~~~~~~~~^~~~
include/poolstl/internal/utils.hpp:89:22: note: shadowed declaration is here
   89 |             Iterator iter;
      |                      ^~~~
include/poolstl/internal/utils.hpp: In constructor ‘poolstl::internal::pivot_predicate<Compare, T>::pivot_predicate(Compare, const T&)’:
include/poolstl/internal/utils.hpp:117:52: warning: declaration of ‘pivot’ shadows a member of ‘poolstl::internal::pivot_predicate<Compare, T>’ [-Wshadow]
  117 |             pivot_predicate(Compare comp, const T& pivot) : comp(comp), pivot(pivot) {}
      |                                           ~~~~~~~~~^~~~~
include/poolstl/internal/utils.hpp:123:21: note: shadowed declaration is here
  123 |             const T pivot;
      |                     ^~~~~
include/poolstl/internal/utils.hpp:117:37: warning: declaration of ‘comp’ shadows a member of ‘poolstl::internal::pivot_predicate<Compare, T>’ [-Wshadow]
  117 |             pivot_predicate(Compare comp, const T& pivot) : comp(comp), pivot(pivot) {}
      |                             ~~~~~~~~^~~~
include/poolstl/internal/utils.hpp:122:21: note: shadowed declaration is here
  122 |             Compare comp;
      |                     ^~~~
include/poolstl/execution: In constructor ‘poolstl::execution::parallel_policy::parallel_policy(task_thread_pool::task_thread_pool*, bool)’:
include/poolstl/execution:60:75: warning: declaration of ‘par_ok’ shadows a member of ‘poolstl::execution::parallel_policy’ [-Wshadow]
   60 |             explicit parallel_policy(ttp::task_thread_pool* on_pool, bool par_ok): on_pool(on_pool), par_ok(par_ok) {}
      |                                                                      ~~~~~^~~~~~
include/poolstl/execution:84:18: note: shadowed declaration is here
   84 |             bool par_ok = true;
      |                  ^~~~~~
include/poolstl/execution:60:61: warning: declaration of ‘on_pool’ shadows a member of ‘poolstl::execution::parallel_policy’ [-Wshadow]
   60 |             explicit parallel_policy(ttp::task_thread_pool* on_pool, bool par_ok): on_pool(on_pool), par_ok(par_ok) {}
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
include/poolstl/execution:83:36: note: shadowed declaration is here
   83 |             ttp::task_thread_pool *on_pool = nullptr;
      |                                    ^~~~~~~
include/poolstl/execution: In constructor ‘poolstl::execution::parallel_policy::parallel_policy(task_thread_pool::task_thread_pool*, bool)’:
include/poolstl/execution:60:75: warning: declaration of ‘par_ok’ shadows a member of ‘poolstl::execution::parallel_policy’ [-Wshadow]
   60 |             explicit parallel_policy(ttp::task_thread_pool* on_pool, bool par_ok): on_pool(on_pool), par_ok(par_ok) {}
      |                                                                      ~~~~~^~~~~~
include/poolstl/execution:84:18: note: shadowed declaration is here
   84 |             bool par_ok = true;
      |                  ^~~~~~
include/poolstl/execution:60:61: warning: declaration of ‘on_pool’ shadows a member of ‘poolstl::execution::parallel_policy’ [-Wshadow]
   60 |             explicit parallel_policy(ttp::task_thread_pool* on_pool, bool par_ok): on_pool(on_pool), par_ok(par_ok) {}
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
include/poolstl/execution:83:36: note: shadowed declaration is here
   83 |             ttp::task_thread_pool *on_pool = nullptr;
      |                                    ^~~~~~~
include/poolstl/execution: In constructor ‘poolstl::execution::parallel_policy::parallel_policy(task_thread_pool::task_thread_pool*, bool)’:
include/poolstl/execution:60:75: warning: declaration of ‘par_ok’ shadows a member of ‘poolstl::execution::parallel_policy’ [-Wshadow]
   60 |             explicit parallel_policy(ttp::task_thread_pool* on_pool, bool par_ok): on_pool(on_pool), par_ok(par_ok) {}
      |                                                                      ~~~~~^~~~~~
include/poolstl/execution:84:18: note: shadowed declaration is here
   84 |             bool par_ok = true;
      |                  ^~~~~~
include/poolstl/execution:60:61: warning: declaration of ‘on_pool’ shadows a member of ‘poolstl::execution::parallel_policy’ [-Wshadow]
   60 |             explicit parallel_policy(ttp::task_thread_pool* on_pool, bool par_ok): on_pool(on_pool), par_ok(par_ok) {}
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
include/poolstl/execution:83:36: note: shadowed declaration is here
   83 |             ttp::task_thread_pool *on_pool = nullptr;
      |                                    ^~~~~~~
include/poolstl/execution: In constructor ‘poolstl::execution::pure_threads_policy::pure_threads_policy(unsigned int, bool)’:
include/poolstl/execution:104:73: warning: declaration of ‘par_ok’ shadows a member of ‘poolstl::execution::pure_threads_policy’ [-Wshadow]
  104 |             explicit pure_threads_policy(unsigned int num_threads, bool par_ok): num_threads(num_threads),
      |                                                                    ~~~~~^~~~~~
include/poolstl/execution:120:18: note: shadowed declaration is here
  120 |             bool par_ok = true;
      |                  ^~~~~~
include/poolstl/execution:104:55: warning: declaration of ‘num_threads’ shadows a member of ‘poolstl::execution::pure_threads_policy’ [-Wshadow]
  104 |             explicit pure_threads_policy(unsigned int num_threads, bool par_ok): num_threads(num_threads),
      |                                          ~~~~~~~~~~~~~^~~~~~~~~~~
include/poolstl/execution:119:26: note: shadowed declaration is here
  119 |             unsigned int num_threads = 1;
      |                          ^~~~~~~~~~~
include/poolstl/execution: In constructor ‘poolstl::execution::pure_threads_policy::pure_threads_policy(unsigned int, bool)’:
include/poolstl/execution:104:73: warning: declaration of ‘par_ok’ shadows a member of ‘poolstl::execution::pure_threads_policy’ [-Wshadow]
  104 |             explicit pure_threads_policy(unsigned int num_threads, bool par_ok): num_threads(num_threads),
      |                                                                    ~~~~~^~~~~~
include/poolstl/execution:120:18: note: shadowed declaration is here
  120 |             bool par_ok = true;
      |                  ^~~~~~
include/poolstl/execution:104:55: warning: declaration of ‘num_threads’ shadows a member of ‘poolstl::execution::pure_threads_policy’ [-Wshadow]
  104 |             explicit pure_threads_policy(unsigned int num_threads, bool par_ok): num_threads(num_threads),
      |                                          ~~~~~~~~~~~~~^~~~~~~~~~~
include/poolstl/execution:119:26: note: shadowed declaration is here
  119 |             unsigned int num_threads = 1;
      |                          ^~~~~~~~~~~
include/poolstl/execution: In constructor ‘poolstl::execution::pure_threads_policy::pure_threads_policy(unsigned int, bool)’:
include/poolstl/execution:104:73: warning: declaration of ‘par_ok’ shadows a member of ‘poolstl::execution::pure_threads_policy’ [-Wshadow]
  104 |             explicit pure_threads_policy(unsigned int num_threads, bool par_ok): num_threads(num_threads),
      |                                                                    ~~~~~^~~~~~
include/poolstl/execution:120:18: note: shadowed declaration is here
  120 |             bool par_ok = true;
      |                  ^~~~~~
include/poolstl/execution:104:55: warning: declaration of ‘num_threads’ shadows a member of ‘poolstl::execution::pure_threads_policy’ [-Wshadow]
  104 |             explicit pure_threads_policy(unsigned int num_threads, bool par_ok): num_threads(num_threads),
      |                                          ~~~~~~~~~~~~~^~~~~~~~~~~
include/poolstl/execution:119:26: note: shadowed declaration is here
  119 |             unsigned int num_threads = 1;
      |                          ^~~~~~~~~~~
In file included from include/poolstl/algorithm:12,
                 from include/poolstl/poolstl.hpp:16:
include/poolstl/internal/ttp_impl.hpp: In lambda function:
include/poolstl/internal/ttp_impl.hpp:32:61: warning: declaration of ‘Op op’ shadows a parameter [-Wshadow]
   32 |                 futures.emplace_back(task_pool.submit([](Op op, const auto& args_fwd) {
      |                                                          ~~~^~
include/poolstl/internal/ttp_impl.hpp:27:48: note: shadowed declaration is here
   27 |         parallel_apply(ExecPolicy &&policy, Op op, const ArgContainer& args_list) {

@schdub schdub linked a pull request Nov 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant