webvm
webvm copied to clipboard
clang++ never finishes compiling
I tried it for >12h and it never finished. I tried to compile the following source code.
#include <iostream>
#include <time.h>
int main()
{
unsigned long tmp, a = 0, b = 1;
std::cout << "Started!" << std::endl;
time_t t1 = time(NULL);
for (unsigned long i = 0uL; i < 10000uL; ++i)
{
for (unsigned long j = 0uL; j < 1000000uL; ++j)
{
tmp = b;
b = a + b;
a = tmp;
}
}
time_t t2 = time(NULL);
time_t dt = t2 - t1;
std::cout << "Finished!" << std::endl;
std::cout << "Result: " << b << std::endl;
std::cout << "Time: " << dt << "s" << std::endl;
return 0;
}
I just tried on Chrome 106, and seems to work as expected (given a couple of minutes with the tab in-focus):

Could you give it another try?
I just stepped by and gave a try. It seems that with -O2 optimization, the compilation will hang.
The developer console will log the following:
CODE AT OFFSET bb df
cxcore.js:1 TODO: FAULT ad2d55cf
cxcore.js:1 CODE 0 67 65
But without -O2 optimization, as tried by @carlopi above, it will work.
Solved in current build
user@:~$ clang++ -O2 issue48.cpp
user@:~$ ./a.out
Started!
Finished!
Result: 4179460381
Time: 25s