David
Wed May 19 16:55:39 CDT 2004
Your assumptions were all correct. The "odd reason" is not so odd. It is
simply my mistake and shame on me that I have not posted at least GNU's
error message which I do now:
/tmp/cckJIUHA.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
My understanding is that the failure occurs at the linking phase, but due to
an error in the compilation phase.
I have a class template with n variables, all participating in a symmetrical
manner in the definition of the one member of the class.
The whole concept is meaningful only for n>=2 where n is the number of the
templates parameters. I will also try to show what I hope I can show of the
class template:
template<typename T1, typename T2, ...> class X {
a_symmetric_construct_composed_of_Ti member;
};
int main() {
X Xi;
return 0;
}
GNU fails of course only when the instantiating statement "X Xi;" is
present. Now hear this about VC++7.1/Borland:
With these compilers, the whole thing, including instantiation and even
actually using and testing the instantiated objects Xi with some follow-up
code it always succeeds when n can satisfy the equation n = k!, for any
integer k where k! means k factorial....
So in the simple case of 2, life are particularly simple because 2 = 2!...
It will next work ok if n=6 because 3! = 6, etc.
I did not deduct my suspicious in the C++ definition from those numbers but
rather the other way around! That is, from the hunch I had about the specs,
I went to check the n = k! cases and found out that indeed in these cases it
succeeds (on MS/Borland) and ONLY on these. Whenever i tried for n = 3, 4,5,
7 etc, it indeed failed.
Is not this something?
To remind you, GNU fails for any n, which from the hunch I have, is more
understandable...
As far as the Comeau C++ compiler, since the tryout does not go beyond the
compilation phase, it serves no purpose in this case.
I am not familiar with the C++ standard but I am going to read it and give
it a try. I usually shy away from documments of that style since they are
written in a cryptic style. Even though it is not driven by the same morbid
reasons physicians still write in Latin and the way lawyers phrase laws,
results are somewhat similar...
David
"tom_usenet" <tom_usenet@hotmail.com> wrote in message
news:mf27a09gv018buphab9g8c519totln3oaq@4ax.com...
> On Thu, 13 May 2004 00:23:49 GMT, "David F"
> <David-White@earthlink.net> wrote:
>
> What do you mean by a "compilable template definition"?
>
> >Assuming of course that the instantiation statement is ok.
>
> What do you mean by "the instantiation statement is ok"?
>
> >As a matter of fact, that very instantiation passes successfuly on VC++
7.1 (and Borland) but since I was suspicious that it was OK there "more by
luck
> >than brain", I checked the same on Linux\GNU were the instantiation
failed.
> >
> >This question is more for people who know well the C++ ISO standard, in
the chapter on template. My hunch is that the problem is with the language
spec.
>
> I'm forced to make some assumptions. By "compilable template definition"
you mean that if you don't have any instantiations of the
> template, it compiles ok. By "the instantiation statement" I'll assume you
mean a statement that referencing the "compilable template
> definition" either in an implicit or explicit instantiation. I'm not sure
what you mean by "is ok", since you then say that it won't compile under
Linux/GNU.
>
> Assuming that, if the instantiation "is ok" on VC++ 7.1 but fails on GCC,
it might mean that the code contains something non-standard that
> gets past the slightly more permissive syntax that VC 7.1 accepts. Or it
could be a bug in GCC. Or something completely different.
>
> But for some odd reason you haven't posted the error that GCC gives you or
the code in question! We're not psychic...
>
> Now, as for compiling a template definition, until it is instantiated only
minimal compilation occurs, particularly with MSVC++ which
> doesn't have two phase name lookup implemented. Nor does GCC I think, but
you can try Comeau C++ which does. This means that it will try to
> compile what it can - everything that doesn't depend on the template
parameter(s).
>
> Tom
> --
> C++ FAQ:
http://www.parashift.com/c++-faq-lite/
> C FAQ:
http://www.eskimo.com/~scs/C-faq/top.html