This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
templ decl for non-templ ?
- To: egcs-bugs at cygnus dot com
- Subject: templ decl for non-templ ?
- From: Kurt Garloff <garloff at hft dot e-technik dot uni-dortmund dot de>
- Date: Thu, 18 Dec 1997 19:46:22 +0000 (Local time zone must be set--see zic manual page)
Hi,
here comes a message that I don't understand ...
garloff@marvin:/home/plasma/numerix/lib/test > egcc -c bug1.cc
bug1.cc: In method `class tensor<T,(rank + r1)> tensor<T,rank>::operator*
(const class tensor<T,r1> &) const':
bug1.cc:18: template definition of non-template `class tensor<T,(rank+r1)>
tensor<T,rank>::operator *(const class tensor<T,r1> &) const'
garloff@marvin:/home/plasma/numerix/lib/test > egcc -v
Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.90.21/specs
gcc version egcs-2.90.21 971202 (egcs-1.00 release)
------------------------------------------------------------------
/* bug1.cc, 18.12.97 by garloff@hft.e-technik.uni-dortmund.de */
template <typename T, unsigned rank>
class tensor
{
protected:
T* data;
public:
tensor () : data (0) {};
tensor (const tensor<T, rank>& t) : data (t.data) {};
template <unsigned r1>
tensor <T, rank + r1> operator * (const tensor <T, r1>& ) const;
};
template <typename T, unsigned rank, unsigned r1>
tensor<T, rank+r1> tensor<T, rank>::operator * (const tensor <T, r1>& t1) const
{
tensor <T, rank+r1> tr;
return tr;
};
int main ()
{
tensor <double, 2> t1; tensor <double, 3> t2;
tensor <double, 5> (t1 * t2);
};
------------------------------------------------------------------------------
AFAIK, the declaration in ll.12/13 declares a templated operator, which
should be possible. The definition in ll.18 ff matches the declaration.
So why is there an error message? Isn't it allowed to do computations
(rank + r1) in template parameters? Hope somebody can fix the bug in egcs
or in my code.
Kurt Garloff
garloff@hft.e-technik.uni-dortmund.de
------------------------------------------------------------------------------
P.S: I found another bug ...
When compiling some code with deeply nested templated classes, I got error
messages from the assembler. -fname-mangling-version-0 fixed it.
I'm gonna submit a full bug-report, when I managed to isolate it.
Here some details: (Maybe someone can figure out if it's the compiler or
the assembler that is wrong here.)
(The file tensortest.s was created by egcc -O3 -S tensortest.cc)
[dortmund@etpvis test]$ as tensortest.s
tensortest.s: Assembler messages:
tensortest.s:7911: Error: Rest of line ignored. First ignored character is `*'.
tensortest.s:7912: Error: ignoring unrecognized symbol type ""
tensortest.s:7912: Error: Rest of line ignored. First ignored character is `*'.
tensortest.s:7913: Error: invalid character '_' in opcode
tensortest.s:10955: Error: expected comma after name
`contract__H2ZdUi5_RCt6Tensor2ZX01UiY11UiUi_t6Tensor2ZX01Ui' in .size directive
tensortest.s:10955: Error: Rest of line ignored. First ignored character is `*'.
--------
tensortest.s:7909
.section .gnu.linkonce.t.contract__H2ZdUi5_RCt6Tensor2ZX01UiY11UiUi_t6Tensor2ZX01Ui *6,"ax",@progbits
.align 4
.weak contract__H2ZdUi5_RCt6Tensor2ZX01UiY11UiUi_t6Tensor2ZX01Ui *6
.type contract__H2ZdUi5_RCt6Tensor2ZX01UiY11UiUi_t6Tensor2ZX01Ui *6,@function
contract__H2ZdUi5_RCt6Tensor2ZX01UiY11UiUi_t6Tensor2ZX01Ui *6:
pushl %ebp
--------
tensortest.s:10954
.Lfe16:
.size contract__H2ZdUi5_RCt6Tensor2ZX01UiY11UiUi_t6Tensor2ZX01Ui *6,.Lfe16-contract__H2ZdUi5_RCt6Tensor2ZX01UiY11UiUi_t6Tensor2ZX01Ui *6
.section .rodata
.LC38:
.string "Swap identical indices"
--------
garloff@marvin:/home/garloff > as -v
GNU assembler version 971211 (i586-linux), using BFD version 971211