g++ with O2 and O3 leads to seg faults