https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85091
--- Comment #9 from Vadim Zeitlin <vz-gcc at zeitlins dot org> --- Another data point: I can also reproduce the problem with the native (i.e. Linux) g++ 7.3 (Debian 7.3.0-12), although it looks slightly differently there: all 3 of the following commands produce different object files: g++-7 -c -std=c++17 -Wnonnull -Woverloaded-virtual -O2 foo.cpp g++-7 -c -std=c++17 -Wnonnull -Woverloaded-virtual -O2 tmp/foo.cpp g++-7 -c -std=c++17 -O2 foo.cpp i.e. moving the file to a subdirectory doesn't mitigate the problem (I probably should have avoided mentioning this in the first place to avoid confusing the matters, sorry). I'm running delta right now to produce a minimized test case for the native compiler, but I am not sure if it's really going to help... The tentative conclusion is that it's not a gcc bug, but a Debian bug, and as it doesn't affect only the cross-compiler, it must be due to one of the Debian-specific patches to gcc itself (thanks to Stephen Kitt, Debian mingw-w64 maintainer, for pointing this out). Unfortunately their list (see https://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-7/debian/patches/ ) is much longer than the list of patches to mingw-w64 and it's not really obvious which one could be to blame...