Skip to content

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

@schdub

Description

@schdub

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) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions