This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/11400] New: std::search_n() makes assumptions about Size parameter


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11400

           Summary: std::search_n() makes assumptions about Size parameter
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com
                CC: gcc-bugs at gcc dot gnu dot org

The only requirement on the Size template parameter of the std::search_n()
template is that it be convertible to integral type (25.1.9, p4). The converse
is not required to hold. The program below fails to compile due to unwarranted
assumptions in the libstdc++ implementation of the algorithm.

Regards
Martin

$ cat t.cpp; g++ -c t.cpp   
#include <algorithm>

struct Integral { operator int() const; };

namespace std {

template int* search_n (int*, int*, Integral, const int&);

}

/build/contrib/gcc-3.2/include/c++/3.2/bits/stl_algo.h: In function 
   `_ForwardIter std::search_n(_ForwardIter, _ForwardIter, _Integer, const 
   _Tp&) [with _ForwardIter = int*, _Integer = Integral, _Tp = int]':
t.cpp:7:   instantiated from here
/build/contrib/gcc-3.2/include/c++/3.2/bits/stl_algo.h:612: conversion from `
   int' to non-scalar type `Integral' requested
/build/contrib/gcc-3.2/include/c++/3.2/bits/stl_algo.h:617: no match for `-- 
   Integral&' operator


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]