https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
--- Comment #2 from Pedro Alves <palves at redhat dot com> --- Looks like a regression at some point: There are no warnings with g++ 5.3.1, either reduced testcase, or with the obvious change to use std::experimental::optional instead of std::optional. Also no warnings with g++ 8.0.0 20170428 + -fno-lifetime-dse or -flifetime-dse=1, perhaps unsurprisingly. The original bug supposedly triggers with g++ 6.3.1 too, though I haven't confirmed with the reduced testcase there. (It's an s390 gdb buildbot, I don't have access to it.)