This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
struct A { operator int & (); operator const int & () const; }; void f(int &); void f(const int &); int main() { const A x = A(); f(x); } gives const_overload.cpp: In function `int main()': const_overload.cpp:12: error: call of overloaded `f(const A&)' is ambiguous const_overload.cpp:7: error: candidates are: void f(int&) const_overload.cpp:8: error: void f(const int&) unless -pedantic is set.
no sorry, we try to a little more pedantic by default in C++.
(In reply to comment #1) > no sorry, we try to a little more pedantic by default in C++. What does that mean? When pedantic is set, it compiles. When it's not set, it doesn't. Pedantic is supposed to be MORE strict!
This is clearly a bug -- x is const, so only the conversion operator to "const int&" can be called. We should accept this with or without -pedantic. Confirmed with 3.3, 3.4 and mainline. It works with 2.95 and 3.2, though, so this is a regression. W.
From Phil's regression hunter: Search converges between 2003-03-04-trunk (#237) and 2003-03 -07-trunk (#238). : Search converges between 2003-03-05-3.3 (#74) and 2003-03-08-3.3 (#75). Related to the fixed bug 9965 and bug 9878.
Subject: Bug 13907 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-02-02 16:26:47 Modified files: gcc/cp : ChangeLog call.c class.c cp-tree.h decl.c init.c pt.c tree.c typeck.c gcc/testsuite : ChangeLog gcc/testsuite/g++.old-deja/g++.mike: net36.C Added files: gcc/testsuite/g++.dg/conversion: op2.C gcc/testsuite/g++.dg/ext: attrib13.C Log message: PR c++/13113 * init.c (build_offset_ref): Improve error recovery for invalid uses of non-static member functions. PR c++/13854 * cp-tree.h (cp_build_type_attribute_variant): New function. * class.c (build_clone): Use cp_build_type_attribute_variant. * decl.c (duplicate_decls): Likewise. * pt.c (copy_default_args_to_explicit_spec): Likewise. (tsubst_function_type): Likewise. * tree.c (build_exception_variant): Check attributes before concluding that two types are the same. (cp_build_type-attribute_variant): New method. * typeck.c (merge_types): Use cp_build_type_attribute_variant. PR c++/13907 * call.c (convert_class_to_reference): Keep better track of pedantically invalid user-defined conversions. PR c++/13113 * g++.old-deja/g++.mike/net36.C: Adjust error messages. PR c++/13854 * g++.dg/ext/attrib13.C: New test. PR c++/13907 * g++.dg/conversion/op2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.26&r2=1.3892.2.27 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.452.2.4&r2=1.452.2.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.595.4.3&r2=1.595.4.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.946.4.2&r2=1.946.4.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.2&r2=1.1174.2.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.356.2.3&r2=1.356.2.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.6&r2=1.816.2.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.360&r2=1.360.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.519.2.3&r2=1.519.2.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.39&r2=1.3389.2.40 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/op2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib13.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.mike/net36.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.7&r2=1.7.14.1
Fixed in GCC 3.4 and GCC 3.5.
Subject: Bug 13907 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-02-02 16:53:17 Modified files: gcc/cp : ChangeLog call.c class.c cp-tree.h decl.c init.c pt.c tree.c typeck.c gcc/testsuite : ChangeLog gcc/testsuite/g++.old-deja/g++.mike: net36.C Added files: gcc/testsuite/g++.dg/conversion: op2.C gcc/testsuite/g++.dg/ext: attrib13.C Log message: PR c++/13113 * init.c (build_offset_ref): Improve error recovery for invalid uses of non-static member functions. PR c++/13854 * cp-tree.h (cp_build_type_attribute_variant): New function. * class.c (build_clone): Use cp_build_type_attribute_variant. * decl.c (duplicate_decls): Likewise. * pt.c (copy_default_args_to_explicit_spec): Likewise. (tsubst_function_type): Likewise. * tree.c (build_exception_variant): Check attributes before concluding that two types are the same. (cp_build_type-attribute_variant): New method. * typeck.c (merge_types): Use cp_build_type_attribute_variant. PR c++/13907 * call.c (convert_class_to_reference): Keep better track of pedantically invalid user-defined conversions. PR c++/13113 * g++.old-deja/g++.mike/net36.C: Adjust error messages. PR c++/13854 * g++.dg/ext/attrib13.C: New test. PR c++/13907 * g++.dg/conversion/op2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3924&r2=1.3925 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.456&r2=1.457 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.599&r2=1.600 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.948&r2=1.949 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1178&r2=1.1179 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.359&r2=1.360 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.824&r2=1.825 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.361&r2=1.362 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.523&r2=1.524 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3451&r2=1.3452 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/op2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/attrib13.C.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.mike/net36.C.diff?cvsroot=gcc&r1=1.7&r2=1.8
Adjust milestone
Subject: Bug 13907 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: gdr@gcc.gnu.org 2004-02-22 16:05:49 Modified files: gcc/cp : ChangeLog call.c Added files: gcc/testsuite/g++.dg/conversion: op2.C Log message: Backport from mainline 2004-02-02 Mark Mitchell <mark@codesourcery.com> PR c++/13907 * call.c (convert_class_to_reference): Keep better track of pedantically invalid user-defined conversions. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.248&r2=1.3076.2.249 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.341.2.37&r2=1.341.2.38 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/conversion/op2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.2.6.1
Backport fix.