g++ only pedwarns about bar but not foo in the following testcase: template<typename _Tv> int foo (int x = -1); template<typename _Tv> int foo (int x = -1) { return 0; } int bar (int x = -1); int bar (int x = -1) { return 0; } int i = foo<int> (); int j = bar (); The warning could be emitted after: --- cp/decl.c.xx 2003-08-05 18:41:19.000000000 -0400 +++ cp/decl.c 2003-08-06 05:07:46.000000000 -0400 @@ -3150,9 +3150,7 @@ duplicate_decls (tree newdecl, tree oldd } } - if (DECL_LANG_SPECIFIC (olddecl) && DECL_USE_TEMPLATE (olddecl)) - ; - else if (TREE_CODE (olddecl) == FUNCTION_DECL) + if (TREE_CODE (olddecl) == FUNCTION_DECL) { tree t1 = TYPE_ARG_TYPES (TREE_TYPE (olddecl)); tree t2 = TYPE_ARG_TYPES (TREE_TYPE (newdecl)); but I wonder whether instantiation is the proper time when the pedwarn should be issued (and not already when duplicate_decls sees template_decl).
This is a duplicate of 11540. W. *** This bug has been marked as a duplicate of 11540 ***