While compiling xaira-1.25 in my OSX (64bit gcc 4.2.1, icu 4.3 xercesc 3.1),
I met a single compile error. It was;
Dict.cpp:419: error: cast from ‘xara_form*’ to ‘int’ loses precision
Dict.cpp:419: error: cast from ‘xara_form*’ to ‘int’ loses precision
It was in CDict::hs()
int CDict::hs(const void* e1,const void* e2)
{
xara_lemma_0* s1=(xara_lemma_0*) e1;
xara_lemma_0* s2=(xara_lemma_0*) e2;
for (int i=0;i<g_nf;i++) {
const xairo_uchar* w1=g_twl->Get(s1->word_);
const xairo_uchar* w2=g_twl->Get(s2->word);
int k=wcscmp(w1,w2);
// int k=g_Collator->compare(g_twl->Get(s1->word),g_twl->Get(s2->word)); // use collator here
if (k != 0) return k;
}
return wcscmp(g_twl->Get((int)s1->pt),g_twl->Get((int) s2->pt));
_
_
The error was on the final return statement. s1->pt, where pt (xara_lemma_0->pt) is a pointer of struct xara_form.
This could be valid, since xara_form has three int in it. Thus, if the address of xara_form is casted into (int), it would become the int value of first structure member. I guess the intention of the code was, s1->pt->ptr (xara_lemma_0->xara_form->ptr this int ptr is the first member of xara_form).
However, the original code fails to compile in a strict 64-bit compiler, or anyplace where the size of a pointer (in my case, 64bit) is different than the size of a int.
I've changed the code to explicitly point ->ptr and compiled it. If this should be done in a different manner, please let me know. _
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, if this was already known bug. -
====
While compiling xaira-1.25 in my OSX (64bit gcc 4.2.1, icu 4.3 xercesc 3.1),
I met a single compile error. It was;
Dict.cpp:419: error: cast from ‘xara_form*’ to ‘int’ loses precision
Dict.cpp:419: error: cast from ‘xara_form*’ to ‘int’ loses precision
It was in CDict::hs()
_
The error was on the final return statement. s1->pt, where pt (xara_lemma_0->pt) is a pointer of struct xara_form.
This could be valid, since xara_form has three int in it. Thus, if the address of xara_form is casted into (int), it would become the int value of first structure member. I guess the intention of the code was, s1->pt->ptr (xara_lemma_0->xara_form->ptr this int ptr is the first member of xara_form).
However, the original code fails to compile in a strict 64-bit compiler, or anyplace where the size of a pointer (in my case, 64bit) is different than the size of a int.
I've changed the code to explicitly point ->ptr and compiled it. If this should be done in a different manner, please let me know. _