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

std::search_n() assumes Size can be incremented

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.1.2, 4.1.3
    • 4.1.4
    • 25. Algorithms
    • None
    • all

    Description

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

      struct Size
      {
      operator int()

      { return 0; }
      private:
      void operator=(Size&);
      };

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

      int main() { return 0; }

      ./include/algorithm.cc: In function 'FwdIter std::_search_n(_FwdIter, _FwdIter, _Dist*, _Size, const _TypeT&, _BinaryPredicate) [with _FwdIter = int*, _Dist = int, _Size = Size, _TypeT = int, _BinaryPredicate = int (*)(int, int)]':
      ./include/algorithm:304: instantiated from '_FwdIter std::search_n(_FwdIter, _FwdIter, _Size, const _TypeT&, _BinaryPredicate) [with _FwdIter = int*, _Size = Size, _TypeT = int, _BinaryPredicate = int (*)(int, int)]'
      t.cpp:11: instantiated from here
      ./include/algorithm.cc:303: error: conversion from 'int' to non-scalar type 'Size' requested
      ./include/algorithm.cc:311: error: no match for 'operator=' in '__matches = 0'
      t.cpp:8: note: candidates are: void Size::operator=(Size&)
      ./include/algorithm.cc:315: error: no match for 'operator+' in '+__matches'
      make: *** [t.o] Error 1

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: