[Bug c++/12672] New: Evals template defaults args that it should not

igodard at pacbell dot net gcc-bugzilla@gcc.gnu.org
Sat Oct 18 08:24:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Evals template defaults args that it should not
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org

The compiler tries to evaluate template default arguments on a result type of an overloaded call on a template function for an overload that cannot be the correct candidate. 

The actual call has two args, and the templated overload with two formals is the target of the call. However, there is also a templated overload with only one argument. That one-arg function has a result type which is itself a template with default args. The compiler tries to evaluate the default args for the type of the template and it blows up because it's undefined for that type.

The problem seems to be that the compiler is not first pruning all candidates with the wrong number of formals before doing type matching. These candidates cannot be the matching overload because they have the wrong number of args. So the compiler is trying to do type matching on impossible overloads, and if that matching (correctly) gets in trouble then you get an error, whereas if arg-number pruning were first then you would get a correct match and no error.

The particular error in the test case is that the evaluation of a default template argument of a type used by the function calls for a member type that doesn't exist for the actual type. However, the actual error in the test doesn't matter - anything that would cause an error during type matching on the wrong (impossible) overload would do.



More information about the Gcc-bugs mailing list