This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/52072] New: Several non-deduced context not recognized


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

             Bug #: 52072
           Summary: Several non-deduced context not recognized
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com


gcc does not properly handle several situations where a non-deduced context
should occur. E.g. the following program is rejected:

//-------
template<class T>
struct ident { typedef T type; };

template<class T>
void f(T, typename ident<T>::type*); // Line 5

struct B {
 typedef int* type;
 operator type();
};

int main() {
 f(0, B()); // Line 13
}
//-------

"In function 'int main()':|
13|error: no matching function for call to 'f(int, B)'|
13|note: candidate is:|
 5|note: template<class T> void f(T, typename ident<T>::type*)|
 5|note:   template argument deduction/substitution failed:|
13|note:   mismatched types 'typename ident<T>::type*' and 'B'|"

It seems that the compiler only accepts situations, where the *complete* type
is wrapped like in

template<class T>
void f(T, typename ident<T*>::type);

But this behaviour does not match with the wording. According to
[temp.deduct.type] p5 b1:

"The non-deduced contexts are:
â The nested-name-specifier of a type that was specified using a qualified-id."

(The same rule exists in C++03, [temp.deduct.type] p4 b1)

The behaviour of gcc looks extraordinary when compared with other compilers,
vc10, clang, or comeau online accept the original code.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]