Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-84

std::fill_n() assumes Size can be decremented

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.1.2
    • 4.1.3
    • 25. Algorithms
    • None
    • all

    Description

      The requirement on the Size template argument to std::fill_n() in lib.alg.fill, p3 is that it be convertible to an integral type which does not imply that it be possible to decrement or otherwise modify its value. I.e., the program below is expected to compile successfully.

      $ cat t.cpp && nice make t
      #include <algorithm>

      struct Size {
      operator int()

      { return 0; }

      private:
      void operator=(Size&);
      };

      template void std::fill_n (int*, Size, const int&);

      int main () { }
      eccp -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG -D_RWSTD_USE_CONFIG -I/build/sebor/eccp-3.6-11s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/../rwtest -I/build/sebor/dev/stdlib/../rwtest/include -I/build/sebor/dev/stdlib/tests/include -A -x --template_directory=/build/sebor/eccp-3.6-11s/lib -g --display_error_number --remarks --diag_suppress 193,236,340,401,261,479,487,678,679,815 t.cpp
      "/build/sebor/dev/stdlib/include/rw/_algobase.h", line 132: error #349: no
      operator "--" matches these operands
      operand types are: – Size
      for (;_n > 0;--n, ++_first)
      ^
      detected during instantiation of "void std::fill_n(_OutputIter,
      _Size, const _TypeT &) [with _OutputIter=int *,
      _Size=Size, _TypeT=int]" at line 9 of "t.cpp"

      1 error detected in the compilation of "t.cpp".
      make: *** [t.o] Error 2

      Attachments

        Issue Links

          Activity

            People

              sebor Martin Sebor
              sebor Martin Sebor
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: