Build fails with LTO due to ODR violations

Description

I tried to build with the following *FLAGS to optimize the build: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Link-Time Optimization is a massively global compiler optimization pass which is pretty handy for producing faster executables. It also has the interesting property that because the compiler does whole-program analysis using bytecode, it can save type information and perform error checks that it normally doesn’t have enough insight for. In particular, checking for ODR issues and checking function type signature mismatches.

Note that all the -Werror=* flags are used to help detect cases where the compiler tries to optimize by assuming UB cannot exist in the source code -- if it does exist, ordinarily the code would be miscompiled, and this says to make the miscompilation a fatal error.

I got this error:

 

This was originally reported downstream at

I reproduced it with versions 8.0.30-23 and 8.3.0-1.

Environment

Gentoo Linux

amd64

gcc (Gentoo 13.3.1_p20240614 p17) 13.3.1 20240614

Activity

Aaditya Dubey 
August 9, 2024 at 3:05 PM

Hi

Thank you for the report.
Verified as described.

Details

Assignee

Reporter

Needs QA

Priority

Created August 8, 2024 at 4:05 AM
Updated August 9, 2024 at 3:05 PM