The failing io test with lto optimization is due to -fdevirtualize option: <<<< Attempt to convert calls to virtual functions to direct calls. This is done both within a procedure and interprocedurally as part of indirect inlining (-findirect-inlining) and interprocedural constant propagation (-fipa-cp). Enabled at levels -O2, -O3, -Os. >>>>
I tried both "-O1 --fdevirtualize -flto" (test fails) and "-0s -fno-devirtualize -flto" (test passes).
i do not know if we can claim this is the compiler bug or octave bug, so have no idea what is the best way to deal with it.