I can reproduce this bug as well on my feisty laptop (with all updates).
Compiling with -O1 works:
pel@pel-laptop:/tmp$ time g++ -O1 -c -o quickbook.o quickbook.cpp
real 0m29.831s
user 0m28.926s
sys 0m0.476s
Compiling with -O2 does not seem to end (I waited 15 minutes which I assume is more than enough)
pel@pel-laptop:/tmp$ time g++ -O2 -c -o quickbook.o quickbook.cpp
(endless loop, or takes a very long time)
According to g++ man page:
-O2 turns on all optimization flags specified by -O. It also turns
on the following optimization flags: -fthread-jumps -fcrossjumping -foptimize-sibling-calls -fcse-follow-jumps -fcse-skip-blocks
-fgcse -fgcse-lm -fexpensive-optimizations -fstrength-reduce -fre‐ run-cse-after-loop -frerun-loop-opt -fcaller-saves -fpeephole2 -fschedule-insns -fschedule-insns2 -fsched-interblock -fsched-spec -fregmove -fstrict-aliasing -fdelete-null-pointer-checks -freorder-blocks -freorder-functions -falign-functions -falign-jumps -falign-loops -falign-labels -ftree-vrp -ftree-pre
So I tried adding on top of -O1, all optimisation turned on by O2, in order to find the one which causes the bug.
However, adding them all on top of -O1 does not trigger the bug:
I can reproduce this bug as well on my feisty laptop (with all updates).
Compiling with -O1 works:
pel@pel- laptop: /tmp$ time g++ -O1 -c -o quickbook.o quickbook.cpp
real 0m29.831s
user 0m28.926s
sys 0m0.476s
Compiling with -O2 does not seem to end (I waited 15 minutes which I assume is more than enough)
pel@pel- laptop: /tmp$ time g++ -O2 -c -o quickbook.o quickbook.cpp
(endless loop, or takes a very long time)
According to g++ man page:
-O2 turns on all optimization flags specified by -O. It also turns
-foptimize- sibling- calls -fcse-follow-jumps -fcse-skip-blocks optimizations -fstrength-reduce -fre‐
run- cse-after- loop -frerun-loop-opt -fcaller-saves -fpeephole2
-fschedule- insns -fschedule-insns2 -fsched-interblock
-fsched- spec -fregmove -fstrict-aliasing
-fdelete- null-pointer- checks -freorder-blocks -freorder-functions
-falign- functions -falign-jumps -falign-loops -falign-labels
-ftree- vrp -ftree-pre
on the following optimization flags: -fthread-jumps -fcrossjumping
-fgcse -fgcse-lm -fexpensive-
So I tried adding on top of -O1, all optimisation turned on by O2, in order to find the one which causes the bug.
However, adding them all on top of -O1 does not trigger the bug:
pel@pel- laptop: /tmp$ time g++ -O1 -fthread-jumps -fcrossjumping -foptimize- sibling- calls -fcse-follow-jumps -fcse-skip-blocks -fgcse -fgcse-lm -fexpensive- optimizations -fstrength-reduce -frerun- cse-after- loop -frerun-loop-opt -fcaller-saves -fpeephole2 -fschedule-insns -fschedule-insns2 -fsched-interblock -fsched-spec -fregmove -fstrict-aliasing -fdelete- null-pointer- checks -freorder-blocks -freorder-functions -falign-functions -falign-jumps -falign-loops -falign-labels -ftree-vrp -ftree-pre -c -o quickbook.o quickbook.cpp
real 0m39.420s
user 0m38.382s
sys 0m0.560s
Does it mean -O2 turns on optimisations that are not documented in g++ man page?