c++/3905: gcc 3.0 bogus error on sizeof (nested-type) in a template

sebor@roguewave.com sebor@roguewave.com
Tue Jul 31 14:56:00 GMT 2001


>Number:         3905
>Category:       c++
>Synopsis:       gcc 3.0 bogus error on sizeof (nested-type) in a template
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 31 14:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     sebor@roguewave.com
>Release:        gcc 3.0
>Organization:
>Environment:

>Description:
This fails to compile with 2.95.2, 2.96 and 3.0. It is
reduced from our implementation of type traits.

Regards
Martin

$ cat t.cpp ; g++ t.cpp
template <class T>
struct S
{
    struct A { };
    struct B { int i [2]; };

    struct C { C (int); };

    static A foo (int, ...);
    static B foo (int, C);

    static T bar ();

    enum {
        val = sizeof (B) == sizeof (foo (0, bar ()))
    };
};


int main ()
{
    return S<char>::val;
}
t.cpp: In instantiation of `S<char>':
t.cpp:22:   instantiated from here
t.cpp:22: invalid use of undefined type `struct S<char>'
t.cpp:17: forward declaration of `struct S<char>'
t.cpp:22: invalid use of undefined type `struct S<char>'
t.cpp:17: forward declaration of `struct S<char>'
>How-To-Repeat:

>Fix:

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



More information about the Gcc-bugs mailing list