[Bug c++/28274] [4.2/4.3/4.4 Regression] Redeclaration with extra default argument doesn't work

reichelt at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Feb 25 21:00:00 GMT 2009



------- Comment #12 from reichelt at gcc dot gnu dot org  2009-02-25 21:00 -------
The culprit is in the function pushdecl_maybe_friend:
Functions declared extern "C" bypass the usual mechanism, because
duplicate_decls isn't called for them (see lines 727ff):

          else if ((DECL_EXTERN_C_FUNCTION_P (x)
                    || DECL_FUNCTION_TEMPLATE_P (x))
                   && is_overloaded_fn (t))
            /* Don't do anything just yet.  */;
          else if (t == wchar_decl_node)
            [...snip...]
          else
            {
              tree olddecl = duplicate_decls (x, t, is_friend);

Later only the binding for such functions is compared, which doesn't
take default parameters into account (see line 778ff):

      if ((TREE_CODE (x) == FUNCTION_DECL)
          && DECL_EXTERN_C_P (x)
          /* We should ignore declarations happening in system headers.  */
          && !DECL_IN_SYSTEM_HEADER (x))
        {
          cxx_binding *function_binding =
              lookup_extern_c_fun_binding_in_all_ns (x);
          if (function_binding
              && !DECL_IN_SYSTEM_HEADER (function_binding->value))
            {
              tree previous = function_binding->value;

              /* In case either x or previous is declared to throw an
exception,
                 make sure both exception specifications are equal.  */
              if (decls_match (x, previous))
               [...snip...]

            }
        }

      if (TREE_CODE (x) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (x))
        check_default_args (x);

I'm not sure how to proceed from here, so unassigning.


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reichelt at gcc dot gnu dot
                   |                            |org
         AssignedTo|reichelt at gcc dot gnu dot |unassigned at gcc dot gnu
                   |org                         |dot org
             Status|REOPENED                    |NEW
      Known to fail|3.4.6 4.0.3 4.1.0 4.1.1     |3.4.6 4.0.3 4.1.0 4.2.0
                   |                            |4.3.0
      Known to work|3.3.6 3.4.0 3.4.5 4.0.2     |3.3.6 3.4.0 3.4.5 4.0.0
                   |4.0.4 4.1.2                 |4.0.1 4.0.2
   Target Milestone|4.0.4                       |4.2.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28274



More information about the Gcc-bugs mailing list