https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86465
--- Comment #2 from Pavel Roskin <proski at gnu dot org> --- Created attachment 44761 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44761&action=edit Heavily simplified example, g++-5 compatible I'm attaching a dumbed down version of the previous example, which compiles with gcc 5.5.0 and newer. gcc 5.5.0 and gcc 6.4.0 don't produce any warning. gcc 7.3.0, 8.1.0 and the today's gcc from the git master branch all produce the warning. That suggests that the issue is indeed related to the one described in bug #86485. The implementation of optional in libstdc++ 7 doesn't trigger a warning, it's the changes in libstdc++ 8 that started triggering it. However, gcc 7 appears to have the same compiler issue.