c++/10449: Totally bogus error message on missing typename (GCC 3.4)

giovannibajo@libero.it giovannibajo@libero.it
Tue Apr 22 01:16:00 GMT 2003


>Number:         10449
>Category:       c++
>Synopsis:       Totally bogus error message on missing typename (GCC 3.4)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 22 01:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Giovanni Bajo
>Release:        g++-3.4 (GCC) 3.4 20030413 (experimental)
>Organization:
>Environment:
cygwin
>Description:
The following legal code gives a totally bogus error message on mainline:

------------------------------
struct Foo
{};

template <typename T>
struct Identity
{
    typedef T type;
};

struct Bar
{
    template <typename T>
    typename Identity<T>::type
    func(T t)
    {
        return Identity<T>::type(t);
    }
};

int main()
{
    Bar b;

    b.func(Foo());
}
------------------------------
gcc34bug1.cpp: In member function `typename Identity<T>::type Bar::func(T)   [with T = Foo]':
gcc34bug1.cpp:24:   instantiated from here
gcc34bug1.cpp:16: error: no match for call to `(Foo) (Foo&)'

The problem in the above code is that line 16 is missing the typename keyword.

This is obviously not reproducible on 3.3 or previous due to the implicit typename extensions. 
>How-To-Repeat:
Compile the above file on 3.4
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list