https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89358
Bug ID: 89358 Summary: Combining -std=c++14 and -std=c++17 objects gives ODR warnings Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: rogero at howzatt dot demon.co.uk CC: marxin at gcc dot gnu.org Target Milestone: --- When object modules compiled with -std=c+14 and -std=c++17 are linked together with -flto there can be warnings about ODR violations in standard library headers Example: -- main.cpp -- #include <map> extern void test(); int main() { std::map<int, int> m; test(); } -- test.cpp -- #include <map> void test() { std::map<int, int> m; } -- ends -- g++ -flto -std=c++17 -c main.cpp g++ -flto -std=c++14 -c test.cpp g++ -flto main.o test.o -- output -- /usr/share/gcc-trunk/include/c++/9.0.0/bits/stl_function.h:381:12: note: type 'struct less' itself violates the C++ One Definition Rule 381 | struct less : public binary_function<_Tp, _Tp, bool> | ^ /usr/share/gcc-trunk/include/c++/9.0.0/bits/stl_tree.h:684:9: note: type 'struct _Rb_tree_impl' itself violates the C++ One Definition Rule 684 | struct _Rb_tree_impl | ^ /usr/share/gcc-trunk/include/c++/9.0.0/bits/stl_map.h:100:11: note: type 'struct _Rep_type' itself violates the C++ One Definition Rule 100 | class map | ^ With gcc trunk from 2019-01-19 on Cygwin. Almost identical messages appear on RHEL with devtools-7 and with gcc 7.30 on WSL