webvm icon indicating copy to clipboard operation
webvm copied to clipboard

clang++ never finishes compiling

Open twischer opened this issue 3 years ago • 1 comments

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;
}

twischer avatar Oct 17 '22 16:10 twischer

I just tried on Chrome 106, and seems to work as expected (given a couple of minutes with the tab in-focus): Screenshot from 2022-10-17 20-16-39

Could you give it another try?

carlopi avatar Oct 17 '22 18:10 carlopi

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.

gzz2000 avatar Dec 31 '22 03:12 gzz2000

Solved in current build

user@:~$ clang++ -O2 issue48.cpp 
user@:~$ ./a.out 
Started!
Finished!
Result: 4179460381
Time: 25s

alexp-sssup avatar May 17 '23 17:05 alexp-sssup