4 ms·
Try it with optimizations on: gcc -std=c99 -O3 -Wall -Wextra test.c -o test g++ -std=c++11 -O3 -Wall -Wextra test.cpp -o test In my experience, C++ compilers
by maxlybbert 12y ago
Try it with optimizations on:
gcc -std=c99 -O3 -Wall -Wextra test.c -o test
g++ -std=c++11 -O3 -Wall -Wextra test.cpp -o test
In my experience, C++ compilers are great at eliding temporaries and various constructor calls (and related memory allocations), but only if optimizations are turned on.
- mike-cardwell 12y agoMade no difference
- maxlybbert 12y agoThanks. It was worth a shot. Which version of GCC are we talking about?
- mike-cardwell 12y agoThe different versions of gcc and clang that I tried are higher up in this thread: https://news.ycombinator.com/item?id=8722519 https://news.ycombinator.com/item?id=8722519