ODR warning
Originally reported downstream in Gentoo at https://bugs.gentoo.org/859628.
Many distributions are exploring use of LTO. With -flto -Werror=odr -Werror=strict-aliasing -Werror=lto-type-mismatch
(with the -Werror
flags to expose issues which often cause miscompilations w/ LTO), lib2geom fails to build as part of Inkscape with:
/var/tmp/portage/media-gfx/inkscape-1.2.2-r4/work/inkscape-1.2.2/src/3rdparty/2geom/src/2geom/solve-bezier.cpp:25:7: error: type ‘struct Bernsteins’ violates the C++ One Definition Rule [-Werror=odr]
25 | class Bernsteins{
| ^
/var/tmp/portage/media-gfx/inkscape-1.2.2-r4/work/inkscape-1.2.2/src/3rdparty/2geom/src/2geom/solve-bezier-one-d.cpp:28:7: note: a different type is defined in another translation unit
28 | class Bernsteins{
| ^
/var/tmp/portage/media-gfx/inkscape-1.2.2-r4/work/inkscape-1.2.2/src/3rdparty/2geom/src/2geom/solve-bezier.cpp:28:26: note: the first difference of corresponding definitions is field ‘solutions’
28 | std::vector<double> &solutions;
| ^
/var/tmp/portage/media-gfx/inkscape-1.2.2-r4/work/inkscape-1.2.2/src/3rdparty/2geom/src/2geom/solve-bezier-one-d.cpp:31:12: note: a field with different name is defined in another translation unit
31 | size_t degree, N;
| ^
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit status
compilation terminated.