https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110424
Bug ID: 110424 Summary: Bogus ODR warning for FMV member function with -flto Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: wwwhhhyyy333 at gmail dot com CC: marxin at gcc dot gnu.org Target Milestone: --- cat m1.h --- #pragma once class A { public: int foo1(); }; --- cat m1.cpp --- #include "m1.h" __attribute__((target_clones("default","arch=icelake-server"))) int A::foo1() { return 0; } --- cat m2.cpp --- #include "m1.h" int main() { A a; return a.foo1(); } --- g++ -flto -Werror m1.cpp m2.cpp -o m2 m1.h:6:7: error: ‘foo1’ violates the C++ One Definition Rule [-Werror=odr] 6 | int foo1(); | ^ m1.cpp:9:1: note: ‘_ZN1A4foo1Ev’ was previously declared here 9 | } | ^ lto1: all warnings being treated as errors The output binary should quite same as the one without lto, so the warning seems to be bogus.