[GCC-XML]Wrong output in version 0.4.1?

Brad King brad.king at kitware.com
Fri Feb 21 17:20:45 EST 2003


> /* file test.h */
> struct C
> {
>     template <class D>
>     void foo()
>     {
>         D d;
>     }
>
>     template <>
>     void foo<int>()
>     {
>         int x;
>     }
> };
[snip]
> intel compiles it without problem.
[snip]
> ] gccxml -fxml=out.xml test.h
>  > test.h:47: explicit specialization in non-namespace scope `struct C'
>  > test.h:48: invalid use of undefined type `struct C'
>  > test.h:40: forward declaration of `struct C'
>  > test.h:49: confused by earlier errors, bailing out

Specialization is not allowed in a class scope (see 14.7.3).  The above
example is invalid C++ code, so intel is wrong to compile it, and gccxml
is correct in giving the error.  To correctly specialize the member, you
need to place the following lines after the definition of struct C:

    template <>
    void C::foo<int>()
    {
        int x;
    }

Ignoring this problem, GCC-XML uses GCC 3.0.4 under the hood to do
parsing.  It will support all of GCC's features even if it thinks it is
simulating msvc 6.  When we say GCC-XML "simulates" a compiler, it does
not duplicate the compiler's bugs and limitations.  The idea is that the
compiler's library of header files is used so that the XML dump sees
approximately the same translation unit as the compiler sees.  This is
useful for tools that generate code based on type information in the XML
dump.  The generated code must have consistent type information with the
compiler that will build it.

-Brad




More information about the gccxml mailing list