Build fails with "error: type ‘struct TOption’ violates the C++ One Definition Rule" #1013

Closed
opened 2026-10-05 04:58:34 +02:00 by adam · 0 comments
Owner

Hi,
As initially reported here, https://bugs.gentoo.org/861470, with certain strict compiler flags, the build fails.

From the git master:

$ rm CMakeCache.txt; export CXXFLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"; cmake .. && make -j$(nproc)
[ 88%] Linking CXX executable znc
/tmp/znc/src/IRCNetwork.cpp:367:8: error: type ‘struct TOption’ violates the C++ One Definition Rule [-Werror=odr]
  367 | struct TOption {
      |        ^
/tmp/znc/src/User.cpp:139:8: note: a different type is defined in another translation unit
  139 | struct TOption {
      |        ^
/tmp/znc/src/IRCNetwork.cpp:369:25: note: the first difference of corresponding definitions is field ‘pSetter’
  369 |     void (CIRCNetwork::*pSetter)(T);
      |                         ^
/tmp/znc/src/User.cpp:141:19: note: a field of same name but different type is defined in another translation unit
  141 |     void (CUser::*pSetter)(T);
      |                   ^
/tmp/znc/src/IRCNetwork.cpp:367:8: error: type ‘struct TOption’ violates the C++ One Definition Rule [-Werror=odr]
  367 | struct TOption {
      |        ^
/tmp/znc/src/User.cpp:139:8: note: a different type is defined in another translation unit
  139 | struct TOption {
      |        ^
/tmp/znc/src/IRCNetwork.cpp:369:25: note: the first difference of corresponding definitions is field ‘pSetter’
  369 |     void (CIRCNetwork::*pSetter)(T);
      |                         ^
/tmp/znc/src/User.cpp:141:19: note: a field of same name but different type is defined in another translation unit
  141 |     void (CUser::*pSetter)(T);
      |                   ^
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/c++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/znc.dir/build.make:105: src/znc] Error 1
make[1]: *** [CMakeFiles/Makefile2:1465: src/CMakeFiles/znc.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
Hi, As initially reported here, https://bugs.gentoo.org/861470, with certain strict compiler flags, the build fails. From the git master: ``` $ rm CMakeCache.txt; export CXXFLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"; cmake .. && make -j$(nproc) [ 88%] Linking CXX executable znc /tmp/znc/src/IRCNetwork.cpp:367:8: error: type ‘struct TOption’ violates the C++ One Definition Rule [-Werror=odr] 367 | struct TOption { | ^ /tmp/znc/src/User.cpp:139:8: note: a different type is defined in another translation unit 139 | struct TOption { | ^ /tmp/znc/src/IRCNetwork.cpp:369:25: note: the first difference of corresponding definitions is field ‘pSetter’ 369 | void (CIRCNetwork::*pSetter)(T); | ^ /tmp/znc/src/User.cpp:141:19: note: a field of same name but different type is defined in another translation unit 141 | void (CUser::*pSetter)(T); | ^ /tmp/znc/src/IRCNetwork.cpp:367:8: error: type ‘struct TOption’ violates the C++ One Definition Rule [-Werror=odr] 367 | struct TOption { | ^ /tmp/znc/src/User.cpp:139:8: note: a different type is defined in another translation unit 139 | struct TOption { | ^ /tmp/znc/src/IRCNetwork.cpp:369:25: note: the first difference of corresponding definitions is field ‘pSetter’ 369 | void (CIRCNetwork::*pSetter)(T); | ^ /tmp/znc/src/User.cpp:141:19: note: a field of same name but different type is defined in another translation unit 141 | void (CUser::*pSetter)(T); | ^ lto1: some warnings being treated as errors lto-wrapper: fatal error: /usr/bin/c++ returned 1 exit status compilation terminated. /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status make[2]: *** [src/CMakeFiles/znc.dir/build.make:105: src/znc] Error 1 make[1]: *** [CMakeFiles/Makefile2:1465: src/CMakeFiles/znc.dir/all] Error 2 make: *** [Makefile:136: all] Error 2 ``` <!-- github-sync-id:1329871047 -->
adam closed this issue 2026-10-05 04:58:34 +02:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#1013