This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/11400] New: std::search_n() makes assumptions about Size parameter
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Jul 2003 00:07:53 -0000
- Subject: [Bug libstdc++/11400] New: std::search_n() makes assumptions about Size parameter
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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