[Bug libstdc++/68880] New: [4.9 Regression][Bisected to r202992] std::operator< overload ignored when using std::lower_bound

2015-12-12 Thread david.ward at ll dot mit.edu
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 
#include 

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 deq;

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

std::deque::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; _Value = const N::S]’:
/usr/inclu

[Bug libstdc++/68880] [4.9 Regression][Bisected to r202992] std::operator< overload ignored when using std::lower_bound

2015-12-13 Thread david.ward at ll dot mit.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68880

David Ward  changed:

   What|Removed |Added

 Status|RESOLVED|CLOSED

--- Comment #3 from David Ward  ---
You are correct; sorry for the noise. I got mixed up by the requirements for
specializing std::less<> versus overloading operator<().

[Bug libstdc++/68880] [4.9 Regression][Bisected to r202992] std::operator< overload ignored when using std::lower_bound

2015-12-14 Thread david.ward at ll dot mit.edu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68880

--- Comment #5 from David Ward  ---
Jonathan, the behavior changed between 4.8 and 4.9. Testing with the 4.9
release showed the new behavior as well. I showed the output from the latest
release to demonstrate that the behavior still exists and hadn't changed back
since 4.9 (and also checked this with SVN trunk).