------- Comment #4 from djh at emss dot co dot za  2008-07-18 07:13 -------
using your t.h file, the following command 
"g++ -v -save-temps  -x c++-header -c t.h -o .obj/test.gch/c++"
gives the following output
<code>
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/opt/gcc4.3.1
Thread model: posix
gcc version 4.3.1 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-o' '.obj/test.gch/c++'
'-shared-libgcc' '-mtune=generic'
 /opt/gcc4.3.1/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1plus -E -quiet -v
-D_GNU_SOURCE t.h -mtune=generic -fpch-preprocess -o t.ii
ignoring nonexistent directory
"/opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../include/c++/4.3.1

/opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../include/c++/4.3.1/i686-pc-linux-gnu

/opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../include/c++/4.3.1/backward
 /usr/local/include
 /opt/gcc4.3.1/include
 /opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/include
 /opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-o' '.obj/test.gch/c++'
'-shared-libgcc' '-mtune=generic'
 /opt/gcc4.3.1/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1plus -fpreprocessed t.ii
-quiet -dumpbase t.h -mtune=generic -auxbase-strip .obj/test.gch/c++ -version
-o t.s --output-pch= .obj/test.gch/c++
GNU C++ (GCC) version 4.3.1 (i686-pc-linux-gnu)
        compiled by GNU C version 4.3.1, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 769fc73960e4feb81129a017258e8f57
</code>

the t.ii file is not that interesting.  Is just the t.h file with 
# 1 "t.h"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "t.h"
added at the top.

The t.cpp file gives us the following output:
<code>
g++ -v -save-temps -include .obj/test t.cpp
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/opt/gcc4.3.1
Thread model: posix
gcc version 4.3.1 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-include' '.obj/test' '-shared-libgcc'
'-mtune=generic'
 /opt/gcc4.3.1/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1plus -E -quiet -v
-D_GNU_SOURCE -include .obj/test t.cpp -mtune=generic -fpch-preprocess -o t.ii
ignoring nonexistent directory
"/opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../include/c++/4.3.1

/opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../include/c++/4.3.1/i686-pc-linux-gnu

/opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/../../../../include/c++/4.3.1/backward
 /usr/local/include
 /opt/gcc4.3.1/include
 /opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/include
 /opt/gcc4.3.1/lib/gcc/i686-pc-linux-gnu/4.3.1/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-include' '.obj/test' '-shared-libgcc'
'-mtune=generic'
 /opt/gcc4.3.1/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1plus -fpreprocessed t.ii
-quiet -dumpbase t.cpp -mtune=generic -auxbase t -version -o t.s
GNU C++ (GCC) version 4.3.1 (i686-pc-linux-gnu)
        compiled by GNU C version 4.3.1, GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 769fc73960e4feb81129a017258e8f57
In file included from t.cpp:2:
t.h:1: error: redefinition of ‘class A’
t.h:2: error: previous definition of ‘class A’
t.h:7: error: prototype for ‘T A::foo1(T (*)[3])’ does not match any in class
‘A’
t.h:4: error: candidate is: template<class T> static T A::foo1(T (*)[3])
In file included from t.cpp:3:
t.h:1: error: redefinition of ‘class A’
t.h:2: error: previous definition of ‘class A’
t.h:7: error: prototype for ‘T A::foo1(T (*)[3])’ does not match any in class
‘A’
t.h:4: error: candidate is: template<class T> static T A::foo1(T (*)[3])
</code>


t.ii contains:
<code>
# 1 "t.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
#pragma GCC pch_preprocess "./.obj/test.gch/c++"
# 1 "t.cpp"
# 1 "t.h" 1
class A
{
    public:
        template <class T> static T foo1(T [3][3]);
};

template <class T> T A::foo1(T t[3][3])
{
    return t[0][1];
}
# 2 "t.cpp" 2
# 1 "t.h" 1
class A
{
    public:
        template <class T> static T foo1(T [3][3]);
};

template <class T> T A::foo1(T t[3][3])
{
    return t[0][1];
}
# 2 "t.cpp" 2

</code>


this was done not with GCC trunk, but GCC 4.3.1.
Thanks


-- 


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

Reply via email to