title: Error while compiling with clang/clang++ [-Werror,-Wrange-loop-constrcut]
body: <p>I'm trying to build a c++ project. While doing so with g++ the project compiles fine. However if I try to compile with clang I get the error:</p>
  <pre><code>ec_read_plan.h:135:19: error: loop variable 'op' creates a copy from type 'const std::pair&lt;ChunkPartType, ReadPlan::ReadOperation&gt;' [-Werror,-Wrange-loop-construct]
       for (const auto op : read_operationss_{
  ec_read_plan.h:135:8: note: use reference type 'const std:pair&lt;ChunkPartType, ReadPlan::ReadOperation&gt; &amp;' to prevent copying
       for (const auto op : read_operations) {
  </code></pre>
  <p>Code is below, I have put a comment next on the line that is giving the error:</p>
  <pre><code>protected:
      void recoverParts(uint8_t *buffer,
                        const std::bitset&lt;Goal::Slice::kMaxPartsCount&gt; &amp;available_parts) const {
          typedef ReedSolomon&lt;slice_traits::ec::kMaxDataCount, slice_traits::ec::kMaxParityCount&gt; RS;
  
          int k = slice_traits::ec::getNumberOfDataParts(slice_type);
          int m = slice_traits::ec::getNumberOfParityParts(slice_type);
          int max_parts = k + m;
  
          RS::ConstFragmentMap data_parts{{0}};
          RS::FragmentMap result_parts{{0}};
          RS::ErasedMap erased;
          RS rs(k, m);
  
          int available_count = 0;
          for (int i = 0; i &lt; max_parts; ++i) {
              if (!available_parts[i] || available_count &gt;= k) {
                  erased.set(i);
              } else {
                  available_count++;
              }
          }
  
          for (const auto op : read_operations) {  //ERROR appears to be here
              data_parts[op.first.getSlicePart()] = buffer + op.second.buffer_offset;
          }
  
          for (int i = 0; i &lt; (int)requested_parts.size(); ++i) {
              if (!available_parts[requested_parts[i].part]) {
                  result_parts[requested_parts[i].part] = buffer + i * buffer_part_size;
              }
          }
  
          rs.recover(data_parts, erased, result_parts, buffer_part_size);
      }
  </code></pre>
  <p>Why am I getting such an error with Clang and how can I fix this? Thank you.</p>
  <p>For anyone who may want to reproduce the error, the source code is here: <a href="https://github.com/lizardfs/lizardfs" rel="nofollow noreferrer">https://github.com/lizardfs/lizardfs</a>. Afterwards do:</p>
  <pre><code>export CC=/usr/bin/clang
  export CC=/usr/bin/clang++
  cd lizardfs
  mkdir build
  cd build
  cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/lizardfs
  make
  </code></pre>