On Thu, 23 Apr 1998, Robert Andrews wrote:
> Thanks again for the template enumeration bug. One of the penalties of
> doing templates 'properly' (i.e. a complete parse and partial check, as
> opposed to just storing the preprocessing tokens) is that you have to
> make allowances for templates all over the place (and I mean everywhere),
> and this one had slipped through the net. The fix is given by the patch
> below; all the files to be altered are in:
>
> TenDRA-4.1.2/src/producers/common/construct
>
> I haven't done a complete validation test run with the patch applied, so
> it is possible that it may break something else, but I doubt it.
>
> - Rob
>
> ----------------------------------------------------------------------------
>
> Robert Andrews
> DERA (Defence Evaluation and Research Agency)
>
> Email: R.Andrews@eris.dera.gov.uk or ra@rivers.dra.hmg.gb
> Phone: +44 1684 894065 Fax: +44 1684 894303
>
> http://alph.dera.gov.uk/TenDRA/
>
>
> **** PATCH START ****
[...]
I've applied your patch, rebuild TenDRA (on Solaris 2.5.1) and the bug
vanished! Hence TenDRA now computes template enums correctly.
BTW, I've tried another well-known small example
****** fact.C ************
#include <stdio.h>
template<int I> struct Fact {
static int value() { return Fact<I-1>::value() * I; }
};
template<> struct Fact<0> {
static int value() { return 1; }
};
main()
{
printf("Fact<4>::value() = %d\n", Fact<4>::value() );
}
and TenDRA choked with the following error messages:
(please don't mention the first warning message, I forgot
to declare main function as returning int).
"fact.C", line 12: Warning:
[ISO 7]: No declaration specifiers in function definition.
[ISO 7.1.5]: Type 'int' inferred.
"fact.C", line 4: Error:
[ISO 14.7.1]: In instantiation of template 'Fact < 1 >::value' (at line 4).
[ISO 13.3.1.1]: Ambiguous call to overloaded function 'Fact < 0 >::value'.
[ISO 13.3.2]: Viable candidates are as follows.
1. 'int Fact < 0 >::value ()' (line 8).
2. 'int Fact < <exp1> >::value ()' (line 4).
egcs g++ and SunPRO C++ 4.2 compiles this example ok.
With optimization turned on both compilers insert 24 (e.g. 4!) in
suitable place.
As far as BLITZ is based on partial specialization (as in example above)
and other tricks (expression templates etc.) it is important to compile
this example by TenDRA faultless for porting BLITZ to your compiler.
Thank you for patch again.
Best regards,
Alexander
--------------------- blitz-dev list --------------------------------
* To subscribe/unsubscribe: mail to majordomo@oonumerics.org, with
"subscribe blitz-dev" or "unsubscribe blitz-dev" in the body of the message
* Blitz++ web page: http://oonumerics.org/blitz/
This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 04:30:04 EST