https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67357
Bug ID: 67357 Summary: -Wodr warnings from types in anonymous namespace Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: rogero at howzatt dot demon.co.uk Target Milestone: --- The following code generates -Wodr warnings wih gcc 5.2.0 $ cat common.hxx template <typename T> struct values{ typedef T const CT; }; $ cat test1.cxx #include "common.hxx" extern void test2(); namespace { struct P { bool One; }; } values<P> test1; int main() { } $ cat test2.cxx #include "common.hxx" namespace { struct P { int Two; }; } values<P> test2; $ /opt/gcc-5.2.0/bin/g++ -flto -Wodr test1.cxx test2.cxx common.hxx:3:21: warning: type 'const struct CT' violates one definition rule [-Wodr] typedef T const CT; ^ common.hxx:3:21: note: a different type is defined in another translation unit typedef T const CT; ^ test1.cxx:7:14: note: the first difference of corresponding definitions is field 'One' bool One; ^ test2.cxx:5:13: note: a field with different name is defined in another translation unit int Two; Where $ /opt/gcc-5.2.0/bin/g++ -v Using built-in specs. COLLECT_GCC=/opt/gcc-5.2.0/bin/g++ COLLECT_LTO_WRAPPER=/opt/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-5.2.0/configure --prefix=/opt/gcc-5.2.0 --enable-cloog-backend --enable-lto --enable-languages=c,c++ --enable-libstdcxx-time --enable-gold --enable-plugins --disable-multilib Thread model: posix gcc version 5.2.0 (GCC) Note: this maybe related to 66180 although (a) this is a gcc 5.2.0 problem and (b) the sample code in comment 5 of that ticket does compile and link cleanly with gcc 5.2.0