https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83371
Bug ID: 83371
Summary: Partial ordering ignores implicit object parameter
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: accepts-invalid, rejects-valid, wrong-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hstong at ca dot ibm.com
Target Milestone: ---
For the following case, given that the constrained and unconstrained parameters
are similar in their constrainedness between the two candidates (just with
different ordering), and the arguments provided match just as well, it seems
that GCC is ignoring the implicit object parameter in the partial ordering in
turn leading to broken behaviour.
### SOURCE (<stdin>):
struct A {
template <typename T> void operator<(T &) &; // #1
};
template <typename T> bool operator<(T &, A &); // #2
bool g(A *ap) { return *ap < *ap; } // GCC picks #2;
// Clang and MSVC says ambiguous
### COMPILER INVOCATION:
g++ -S -o /dev/null -x c++ -
### ACTUAL OUTPUT:
(Clean compile)
### EXPECTED OUTPUT:
(Error message)
### COMPILER VERSION INFO (g++ -v):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head
--enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl
--enable-checking=release --disable-nls --enable-lto
LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
gcc version 8.0.0 20171210 (experimental) (GCC)