https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68880

            Bug ID: 68880
           Summary: [4.9 Regression][Bisected to r202992] std::operator<
                    overload ignored when using std::lower_bound
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.ward at ll dot mit.edu
                CC: fdumont at gcc dot gnu.org
  Target Milestone: ---

Created attachment 37018
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37018&action=edit
Preprocessed file

Prior to r202992 the following compiles without any warning:



#include <deque>
#include <algorithm>

namespace N
{
        struct S
        {
                int x;
                int y;
        };
}

namespace std
{
        bool operator< (const N::S &lhs,
                        const N::S &rhs)
        {
                return lhs.y < rhs.y;
        }
}

class C
{
public:
        void f()
        {
                std::deque<N::S> deq;

                N::S val;
                val.y = 10;

                std::deque<N::S>::iterator it = std::lower_bound(deq.begin(),
                                                                 deq.end(),
                                                                 val);
        }
};

int main()
{
        C obj;
        obj.f();
}



Now it fails, as it no longer recognizes the std::operator< overload. The
output below is from gcc 5.3.0, but I just checked that it is still broken in
SVN trunk:



# g++ -v -save-temps svn-r202992-regression.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-5.3.0/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --enable-libmpx --with-system-zlib --with-isl
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu
--disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object
--enable-linker-build-id --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu
--enable-gnu-indirect-function --disable-multilib --disable-werror
--enable-checking=release
Thread model: posix
gcc version 5.3.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/cc1plus -E -quiet -v -D_GNU_SOURCE
svn-r202992-regression.cpp -mtune=generic -march=x86-64 -fpch-preprocess -o
svn-r202992-regression.ii
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0

/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/x86_64-unknown-linux-gnu

/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/backward
 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include
 /usr/local/include
 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/cc1plus -fpreprocessed
svn-r202992-regression.ii -quiet -dumpbase svn-r202992-regression.cpp
-mtune=generic -march=x86-64 -auxbase svn-r202992-regression -version -o
svn-r202992-regression.s
GNU C++ (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 5.3.0, GMP version 6.1.0, MPFR version
3.1.3-p5, MPC version 1.0.3
warning: MPFR header version 3.1.3-p5 differs from library version 3.1.3-p4.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=127710
GNU C++ (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 5.3.0, GMP version 6.1.0, MPFR version
3.1.3-p5, MPC version 1.0.3
warning: MPFR header version 3.1.3-p5 differs from library version 3.1.3-p4.
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=127710
Compiler executable checksum: f5781c340dcd4c5ddaa4fbe9faee3243
In file included from /usr/include/c++/5.3.0/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5.3.0/deque:60,
                 from svn-r202992-regression.cpp:1:
/usr/include/c++/5.3.0/bits/predefined_ops.h: In instantiation of ‘bool
__gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with
_Iterator = std::_Deque_iterator<N::S, N::S&, N::S*>; _Value = const N::S]’:
/usr/include/c++/5.3.0/bits/stl_algobase.h:971:14:   required from
‘_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const
_Tp&, _Compare) [with _ForwardIterator = std::_Deque_iterator<N::S, N::S&,
N::S*>; _Tp = N::S; _Compare = __gnu_cxx::__ops::_Iter_less_val]’
/usr/include/c++/5.3.0/bits/stl_algobase.h:1005:32:   required from
‘_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const
_Tp&) [with _ForwardIterator = std::_Deque_iterator<N::S, N::S&, N::S*>; _Tp =
N::S]’
svn-r202992-regression.cpp:34:55:   required from here
/usr/include/c++/5.3.0/bits/predefined_ops.h:55:22: error: no match for
‘operator<’ (operand types are ‘N::S’ and ‘const N::S’)
       { return *__it < __val; }
                      ^
In file included from /usr/include/c++/5.3.0/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5.3.0/deque:60,
                 from svn-r202992-regression.cpp:1:
/usr/include/c++/5.3.0/bits/stl_iterator.h:849:5: note: candidate:
template<class _IteratorL, class _IteratorR, class _Container> bool
__gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL,
_Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
     ^
/usr/include/c++/5.3.0/bits/stl_iterator.h:849:5: note:   template argument
deduction/substitution failed:
In file included from /usr/include/c++/5.3.0/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5.3.0/deque:60,
                 from svn-r202992-regression.cpp:1:
/usr/include/c++/5.3.0/bits/predefined_ops.h:55:22: note:   ‘N::S’ is not
derived from ‘const __gnu_cxx::__normal_iterator<_IteratorL, _Container>’
       { return *__it < __val; }
                      ^
In file included from /usr/include/c++/5.3.0/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/5.3.0/deque:60,
                 from svn-r202992-regression.cpp:1:
/usr/include/c++/5.3.0/bits/stl_iterator.h:856:5: note: candidate:
template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const
__gnu_cxx::__normal_iterator<_Iterator, _Container>&, const
__gnu_cxx::__normal_iterator<_Iterator, _Container>&)
     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
     ^
/usr/include/c++/5.3.0/bits/stl_iterator.h:856:5: note:   template argument
deduction/substitution failed:
In file included from /usr/include/c++/5.3.0/bits/stl_algobase.h:71:0,
                 from /usr/include/c++/5.3.0/deque:60,
                 from svn-r202992-regression.cpp:1:
/usr/include/c++/5.3.0/bits/predefined_ops.h:55:22: note:   ‘N::S’ is not
derived from ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’
       { return *__it < __val; }
                      ^

Reply via email to