https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61216
Bug ID: 61216 Summary: wrong name lookup for operator functions with using-declaration Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: trivial Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: palpatin91 at mail dot ru In GCC 4.8.1 for Windows XP: --------------------------------------------- gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=f:/dev-cpp/mingw32/bin/../libexec/gcc/mingw32/4.8.1/lto-wrap per.exe Target: mingw32 Configured with: ../gcc-4.8.1/configure --prefix=/mingw --host=mingw32 --build=m ingw32 --without-pic --enable-shared --enable-static --with-gnu-ld --enable-lto --enable-libssp --disable-multilib --enable-languages=c,c++,fortran,objc,obj-c++ ,ada --disable-sjlj-exceptions --with-dwarf2 --disable-win32-registry --enable-l ibstdcxx-debug --enable-version-specific-runtime-libs --with-gmp=/usr/src/pkg/gm p-5.1.2-1-mingw32-src/bld --with-mpc=/usr/src/pkg/mpc-1.0.1-1-mingw32-src/bld -- with-mpfr= --with-system-zlib --with-gnu-as --enable-decimal-float=yes --enable- libgomp --enable-threads --with-libiconv-prefix=/mingw32 --with-libintl-prefix=/ mingw --disable-bootstrap LDFLAGS=-s CFLAGS=-D_USE_32BIT_TIME_T Thread model: win32 gcc version 4.8.1 (GCC) --------------------------------------------- following code fragment gives compilation error: --------------------------------------------- class C { }; namespace N { C& operator ++(C& obj) { return obj; } } C& operator ++(C& obj) { return obj; } int main() { using N::operator ++; C c; ++c; } --------------------------------------------- main.cpp: In function 'int main()': main.cpp:69:2: error: ambiguous overload for 'operator++' (operand type is 'C') ++c; ^ main.cpp:69:2: note: candidates are: main.cpp:60:4: note: C& N::operator++(C&) C& operator ++(C& obj) { return obj; } ^ main.cpp:63:4: note: C& operator++(C&) C& operator ++(C& obj) { return obj; } ^ --------------------------------------------- But according to 13.3.1.2p3: "The set of non-member candidates is the result of the unqualified lookup of operator@ in the context of the expression according to the usual rules for name lookup in unqualified function calls (3.4.2) except that all member functions are ignored." And the following code compiles just fine: --------------------------------------------- namespace N { void f() {} } void f() {} int main() { using N::f; f(); } --------------------------------------------- So I assume in case of operator functions it should compile also and choose N::operator ++ version