Sheng Zhou
2010-Nov-10 03:07 UTC
[LLVMdev] llvm-gcc not compatible with gcc on a small case?
I found a case which gcc can compile while llvm-gcc can not. I'm using the gcc4.1 and the most recent llvm-gcc. Here is the case: template <int N> class T { public: int V; }; T<4> test(T<4> a[4][8]) { return a[3][3]; } llvm-gcc dumped: fail.cpp: In function \u2018T<4> test(T<4> (*)[8])\u2019: fail.cpp:7: error: invalid use of incomplete type \u2018class T<4>\u2019 fail.cpp:2: error: declaration of \u2018class T<4>\u2019 Guys, any idea for this issue? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101110/9bac5119/attachment.html>
Samuel Crow
2010-Nov-10 03:27 UTC
[LLVMdev] Fw: llvm-gcc not compatible with gcc on a small case?
Whoops, forgot to CC: the list.> >----- Forwarded Message ---- >From: Samuel Crow <samuraileumas at yahoo.com> >To: Sheng Zhou <zhousheng00 at gmail.com> >Sent: Tue, November 9, 2010 9:26:51 PM >Subject: Re: [LLVMdev] llvm-gcc not compatible with gcc on a small case? > > >Hi Sheng Zhou, > > >It shouldn't compile. You have the method declared inside the templated class >thus indicating infinite recursion. It should be outside the template shouldn't >it? What was the command line you used to compile it under both GCC and >LLVM-GCC? > > >--Sam Crow > >> >>From: Sheng Zhou <zhousheng00 at gmail.com> >>To: llvmdev at cs.uiuc.edu >>Sent: Tue, November 9, 2010 9:07:46 PM >>Subject: [LLVMdev] llvm-gcc not compatible with gcc on a small case? >> >>I found a case which gcc can compile while llvm-gcc can not. I'm using the >>gcc4.1 and the most recent llvm-gcc. >> >>Here is the case: >> >>template <int N> >>class T { >>public: >> int V; >>}; >> >>T<4> test(T<4> a[4][8]) { >> return a[3][3]; >>} >> >> >> >>llvm-gcc dumped: >> >>fail.cpp: In function \u2018T<4> test(T<4> (*)[8])\u2019: >>fail.cpp:7: error: invalid use of incomplete type \u2018class T<4>\u2019 >>fail.cpp:2: error: declaration of \u2018class T<4>\u2019 >> >>Guys, any idea for this issue? >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101109/5c5229a3/attachment.html>
Isaac Dupree
2010-Nov-10 03:39 UTC
[LLVMdev] Fw: llvm-gcc not compatible with gcc on a small case?
On 11/09/10 22:27, Samuel Crow wrote:>> It shouldn't compile. You have the method declared inside the templated class >> thus indicating infinite recursion.No, the method is not in the class. It is a function that returns a T<4> and takes (approximately) a reference to a multidimensional array of T<4>s. In fact it compiles fine for me, with no warnings, under both g++ -Wall -c thing.cpp # version 4.5.1 clang++ -Wall -c thing.cpp # version 2.8 Perhaps gcc-4.2 (the base GCC version of llvm-gcc, unless you have a really old one, check llvm-gcc --version ?) gets confused about that code, or such? -Isaac