W
Wagner Dias
Hi,
The following code causes either a system reboot or a system freeze
after around 15-20 minutes.
The code was compiled in Visual C++ 6.0, as well as in lcc-win32 (with
proper replacement of new/delete with malloc/free), latest version as
of Mar 28, 2005, in the following system:
Microsoft Windows XP Professional
Version 2002
Service Pack 1
running on an
AMD Athlon XP 1900+ 1.6 GHz
512MB RAM
This seems like a OS-related issue, since this code causes reboot or
freeze when generated by both compilers.
Any help is appreciated, thanks in advance,
Wagner
=========================
double intersection_size(const unsigned int *A, unsigned int szA,
const unsigned int *B, unsigned int szB)
{
double wresult = 0.0;
// Obs: the elements must be ordered.
unsigned int ii, jj;
for (ii = 0, jj = 0; ii < szA && jj < szB; ) {
unsigned int a, b;
a = A[ii];
b = B[jj];
// the element pointed by ii is in the intersection
if (a == b) {
wresult += 1.0;
ii++;
jj++;
}
// the element pointed by ii is in A but not in the intersection
else if (a < b) {
ii++;
}
// the element pointed by jj is in B but not in the intersection
else {
jj++;
}
}
return wresult;
}
int main(void)
{
unsigned int *v1, *v2;
v1 = new unsigned int[3000];
v2 = new unsigned int[3000];
for (unsigned int i = 0; i < 3000; i++) {
v1 = i;
v2 = i+1500;
}
for ( ; ; ) intersection_size(v1, 3000, v2, 3000);
delete [] v1;
delete [] v2;
return 0;
}
=========================
The following code causes either a system reboot or a system freeze
after around 15-20 minutes.
The code was compiled in Visual C++ 6.0, as well as in lcc-win32 (with
proper replacement of new/delete with malloc/free), latest version as
of Mar 28, 2005, in the following system:
Microsoft Windows XP Professional
Version 2002
Service Pack 1
running on an
AMD Athlon XP 1900+ 1.6 GHz
512MB RAM
This seems like a OS-related issue, since this code causes reboot or
freeze when generated by both compilers.
Any help is appreciated, thanks in advance,
Wagner
=========================
double intersection_size(const unsigned int *A, unsigned int szA,
const unsigned int *B, unsigned int szB)
{
double wresult = 0.0;
// Obs: the elements must be ordered.
unsigned int ii, jj;
for (ii = 0, jj = 0; ii < szA && jj < szB; ) {
unsigned int a, b;
a = A[ii];
b = B[jj];
// the element pointed by ii is in the intersection
if (a == b) {
wresult += 1.0;
ii++;
jj++;
}
// the element pointed by ii is in A but not in the intersection
else if (a < b) {
ii++;
}
// the element pointed by jj is in B but not in the intersection
else {
jj++;
}
}
return wresult;
}
int main(void)
{
unsigned int *v1, *v2;
v1 = new unsigned int[3000];
v2 = new unsigned int[3000];
for (unsigned int i = 0; i < 3000; i++) {
v1 = i;
v2 = i+1500;
}
for ( ; ; ) intersection_size(v1, 3000, v2, 3000);
delete [] v1;
delete [] v2;
return 0;
}
=========================