[Bug lto/89358] [7/8/9 Regression] Combining -std=c++14 and -std=c++17 objects gives ODR warnings

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 15 10:17:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89358

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I see this warning even when compiling preprocessed source that was all
produced using -std=c++14 (so the input source code is identical):

g++ -E main.cpp -o main.ii
g++ -E test.cpp -o test.ii
g++ -flto -c main.ii -std=c++17
g++ -flto -c test.ii
g++ -flto main.o test.o
/usr/include/c++/8/bits/stl_function.h:381:12: note: type ‘struct less’ itself
violates the C++ One Definition Rule
     struct less : public binary_function<_Tp, _Tp, bool>
            ^

So this appears to be a difference introduced by the compiler, not the source
code. Either there's a compiler bug causing unwanted differences depending on
-sd options, or the warnings need to be suppressed because the differences are
intended.


More information about the Gcc-bugs mailing list