Compile this file with g++-3.2 I get a long error message starting with: x.cxx:6: ambiguous overload for `std::ostream& << anonymous>' operator Replacing the call to strlen with a locally defined function returning size_t or casting the result of strlen causes the compilation to succeed. Release: 3.2 Environment: linux Reproduced with RH 8.0 released compiler How-To-Repeat: g++ x.cxx
Fix: http://gcc.gnu.org/ml/gcc-patches/2002-12/msg00019.html
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. This can be reduced to the following: ---------------------------------- typedef unsigned int size_t; extern size_t strlen (__const char *__s) throw () __attribute__((__pure__)); static void foo(size_t); static void foo(double); main() { foo(strlen("hello")); } ---------------------------------- Which gives me with 3.2.1 and 3.3: tmp/g> /home/bangerth/bin/gcc-3.3x-pre/bin/c++ -c y.ii y.ii: In function `int main()': y.ii:8: error: call of overloaded `foo(<anonymous>)' is ambiguous y.ii:4: error: candidates are: void foo(unsigned int) y.ii:5: error: void foo(double) This used to work with 2.95, but does no more; I think the time for marking regressions with "high" has passed, so I leave it in the present "medium" state.
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu> To: gcc-gnats@gcc.gnu.org Cc: Subject: Re: c++/8493: Bad interaction of strlen and overload resolution Date: Thu, 7 Nov 2002 17:21:48 -0600 (CST) This one may be related to PR 8332. ------------------------------------------------------------------------- Wolfgang Bangerth email: bangerth@ticam.utexas.edu www: http://www.ticam.utexas.edu/~bangerth
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed in GCC 3.2.2/GCC 3.3.
From: mmitchel@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/8493 Date: 1 Dec 2002 17:51:51 -0000 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2002-12-01 09:51:51 Modified files: gcc : ChangeLog builtin-types.def builtins.c c-common.c c-common.h c-format.c tree.h gcc/cp : ChangeLog decl.c decl2.c except.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: strlen1.C Log message: PR c++/8332 PR c++/8493 * decl.c (cxx_init_decl_processing): Use size_type_node, not c_size_type_node. * decl2.c (coerce_new_type): Likewise. * except.c (do_allocate_exception): Likewise. * builtin-types.def (BT_SIZE): Use size_type_node. * builtins.c (fold_builtin): Make the builtin strlen returns a size_t, not a sizetype. * c-common.c (c_sizeof_or_alignof_type): Use size_type_node, not c_size_type_node. (c_alignof_expr): Likewise. (c_common_nodes_and_builtins): Likewise. * c-common.h (CTI_C_SIZE_TYPE): Remove. (c_size_type_node): Likewise. * c-format.c (T_ST): Use size_type_node, not c_size_type_node. * tree.h (TI_SIZE_TYPE): New enumeral. (size_type_node): Likewise. PR c++/8332 PR c++/8493 * g++.dg/template/strlen1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.16031&r2=1.16032 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtin-types.def.diff?cvsroot=gcc&r1=1.9&r2=1.10 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtins.c.diff?cvsroot=gcc&r1=1.164&r2=1.165 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.c.diff?cvsroot=gcc&r1=1.391&r2=1.392 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.h.diff?cvsroot=gcc&r1=1.163&r2=1.164 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-format.c.diff?cvsroot=gcc&r1=1.29&r2=1.30 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&r1=1.364&r2=1.365 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3060&r2=1.3061 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.961&r2=1.962 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.573&r2=1.574 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/except.c.diff?cvsroot=gcc&r1=1.147&r2=1.148 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2242&r2=1.2243 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/strlen1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
From: mmitchel@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/8493 Date: 1 Dec 2002 17:51:52 -0000 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2002-12-01 09:51:51 Modified files: gcc : ChangeLog builtin-types.def builtins.c c-common.c c-common.h c-format.c tree.h gcc/cp : ChangeLog decl.c decl2.c except.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: strlen1.C Log message: PR c++/8332 PR c++/8493 * decl.c (cxx_init_decl_processing): Use size_type_node, not c_size_type_node. * decl2.c (coerce_new_type): Likewise. * except.c (do_allocate_exception): Likewise. * builtin-types.def (BT_SIZE): Use size_type_node. * builtins.c (fold_builtin): Make the builtin strlen returns a size_t, not a sizetype. * c-common.c (c_sizeof_or_alignof_type): Use size_type_node, not c_size_type_node. (c_alignof_expr): Likewise. (c_common_nodes_and_builtins): Likewise. * c-common.h (CTI_C_SIZE_TYPE): Remove. (c_size_type_node): Likewise. * c-format.c (T_ST): Use size_type_node, not c_size_type_node. * tree.h (TI_SIZE_TYPE): New enumeral. (size_type_node): Likewise. PR c++/8332 PR c++/8493 * g++.dg/template/strlen1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.16031&r2=1.16032 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtin-types.def.diff?cvsroot=gcc&r1=1.9&r2=1.10 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtins.c.diff?cvsroot=gcc&r1=1.164&r2=1.165 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.c.diff?cvsroot=gcc&r1=1.391&r2=1.392 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.h.diff?cvsroot=gcc&r1=1.163&r2=1.164 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-format.c.diff?cvsroot=gcc&r1=1.29&r2=1.30 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&r1=1.364&r2=1.365 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3060&r2=1.3061 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.961&r2=1.962 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&r1=1.573&r2=1.574 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/except.c.diff?cvsroot=gcc&r1=1.147&r2=1.148 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2242&r2=1.2243 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/strlen1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
From: mmitchel@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: c++/8493 Date: 1 Dec 2002 18:19:15 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_2-branch Changes by: mmitchel@gcc.gnu.org 2002-12-01 10:19:15 Modified files: gcc : ChangeLog builtin-types.def builtins.c c-common.c c-common.h c-format.c c-typeck.c tree.h gcc/cp : ChangeLog decl.c decl2.c except.c typeck.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: strlen1.C Log message: PR c++/8332 PR c++/8493 * decl.c (cxx_init_decl_processing): Use size_type_node, not c_size_type_node. * decl2.c (coerce_new_type): Likewise. * except.c (do_allocate_exception): Likewise. * typeck.c (c_sizeof): Likewise. (c_sizeof_nowarn): Likewise. * builtin-types.def (BT_SIZE): Use size_type_node. * builtins.c (fold_builtin): Make the builtin strlen returns a size_t, not a sizetype. * c-common.c (c_alignof): Use size_type_node, not c_size_type_node. (c_alignof_expr): Likewise. (c_common_nodes_and_builtins): Likewise. * c-common.h (CTI_C_SIZE_TYPE): Remove. (c_size_type_node): Likewise. * c-format.c (T_ST): Use size_type_node, not c_size_type_node. * tree.h (TI_SIZE_TYPE): New enumeral. (size_type_node): Likewise. PR c++/8332 PR c++/8493 * g++.dg/template/strlen1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.13152.2.657.2.152&r2=1.13152.2.657.2.153 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtin-types.def.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.5&r2=1.5.6.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtins.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.142.2.2&r2=1.142.2.2.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.294.2.9.2.2&r2=1.294.2.9.2.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.h.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.115.2.3.4.1&r2=1.115.2.3.4.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-format.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.17&r2=1.17.6.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.180.2.2.4.2&r2=1.180.2.2.4.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.308.2.2.4.2&r2=1.308.2.2.4.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.45&r2=1.2685.2.114.2.46 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.866.2.36.2.12&r2=1.866.2.36.2.13 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.520.2.7.2.8&r2=1.520.2.7.2.9 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/except.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.140&r2=1.140.12.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.388.2.10.2.3&r2=1.388.2.10.2.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.60&r2=1.1672.2.166.2.61 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/strlen1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1