ODR Violations when building with LTO
kostadinsh opened this issue · comments
Some ODR violations appear as warnings when building with LTO
GCC Version is gcc (Gentoo Hardened 13.2.0 p3) 13.2.0
Steps to reproduce:
git clone https://github.com/mstorsjo/fdk-aac.git
export CXXFLAGS="-O2 -flto=auto"
mkdir fdk-aac/build && cd fdk-aac/build
cmake .. && make VERBOSE=1
libMpegTPDec/src/tpdec_adts.h:141:8: warning: type 'struct STRUCT_ADTS' violates the C++ One Definition Rule [-Wodr]
141 | struct STRUCT_ADTS {
| ^
libMpegTPEnc/src/tpenc_adts.h:133:3: note: a different type is defined in another translation unit
133 | } STRUCT_ADTS;
| ^
libMpegTPDec/src/tpdec_adts.h:142:18: note: the first difference of corresponding definitions is field 'bs'
142 | STRUCT_ADTS_BS bs;
| ^
libMpegTPEnc/src/tpenc_adts.h:111:7: note: a field with different name is defined in another translation unit
111 | INT sample_freq;
| ^
libMpegTPDec/src/tpdec_latm.h:126:3: warning: type 'struct LATM_LAYER_INFO' violates the C++ One Definition Rule [-Wodr]
126 | } LATM_LAYER_INFO;
| ^
libMpegTPEnc/src/tpenc_latm.h:130:3: note: a different type is defined in another translation unit
130 | } LATM_LAYER_INFO;
| ^
libMpegTPDec/src/tpdec_latm.h:122:8: note: the first difference of corresponding definitions is field 'm_frameLengthType'
122 | UINT m_frameLengthType;
| ^
libMpegTPEnc/src/tpenc_latm.h:126:14: note: a field with different name is defined in another translation unit
126 | signed int frameLengthType;
| ^
libSACdec/src/sac_dec.h:201:3: warning: type 'struct LOSSLESSDATA' violates the C++ One Definition Rule [-Wodr]
201 | } LOSSLESSDATA;
| ^
libSACenc/src/sacenc_bitstream.h:241:3: note: a different type is defined in another translation unit
241 | } LOSSLESSDATA;
| ^
libSACdec/src/sac_dec.h:196:9: note: the first difference of corresponding definitions is field 'bsXXXDataMode'
196 | SCHAR bsXXXDataMode[MAX_PARAMETER_SETS];
| ^
libSACenc/src/sacenc_bitstream.h:236:9: note: a field of same name but different type is defined in another translation unit
236 | UCHAR bsXXXDataMode[SACENC_MAX_NUM_BOXES][MAX_NUM_PARAMS];
| ^
libSACdec/src/sac_dec.h:201:3: note: array types have different bounds
201 | } LOSSLESSDATA;
| ^
./libSBRenc/include/../src/bit_sbr.h:131:8: warning: type 'struct SBR_HEADER_DATA' violates the C++ One Definition Rule [-Wodr]
131 | struct SBR_HEADER_DATA {
| ^
libSBRdec/src/env_extr.h:295:3: note: a different type is defined in another translation unit
295 | } SBR_HEADER_DATA;
| ^
./libSBRenc/include/../src/bit_sbr.h:132:11: note: the first difference of corresponding definitions is field 'sbr_amp_res'
132 | AMP_RES sbr_amp_res;
| ^
libSBRdec/src/env_extr.h:271:3: note: a field with different name is defined in another translation unit
271 | syncState; /*!< The current initialization status of the header */
| ^
./libSBRenc/include/../src/ton_corr.h:131:3: warning: type 'struct PATCH_PARAM' violates the C++ One Definition Rule [-Wodr]
131 | } PATCH_PARAM;
| ^
libSBRdec/src/lpp_tran.h:187:3: note: a different type is defined in another translation unit
187 | } PATCH_PARAM;
| ^
./libSBRenc/include/../src/ton_corr.h:120:7: note: the first difference of corresponding definitions is field 'sourceStartBand'
120 | INT sourceStartBand; /*!< first band in lowbands where to take the samples
| ^
libSBRdec/src/lpp_tran.h:174:9: note: a field of same name but different type is defined in another translation unit
174 | UCHAR sourceStartBand; /*!< first band in lowbands where to take the samples
| ^
./libSBRenc/include/../src/ton_corr.h:131:3: note: type 'INT' should match type 'UCHAR'
131 | } PATCH_PARAM;
| ^
./libSBRenc/include/../src/sbr.h:129:16: warning: type 'struct SBR_CHANNEL' violates the C++ One Definition Rule [-Wodr]
129 | typedef struct SBR_CHANNEL {
| ^
libSBRdec/src/sbr_dec.h:173:3: note: a different type is defined in another translation unit
173 | } SBR_CHANNEL;
| ^
./libSBRenc/include/../src/sbr.h:130:22: note: the first difference of corresponding definitions is field 'hEnvChannel'
130 | struct ENV_CHANNEL hEnvChannel;
| ^
libSBRdec/src/sbr_dec.h:170:18: note: a field with different name is defined in another translation unit
170 | SBR_FRAME_DATA frameData[(1) + 1];
| ^
./libFDK/include/nlc_dec.h:129:3: warning: type 'DATA_TYPE' violates the C++ One Definition Rule [-Wodr]
129 | } DATA_TYPE;
| ^
libSACenc/src/sacenc_nlc_enc.h:120:3: note: an enum with different number of values is defined in another translation unit
120 | } DATA_TYPE;
| ^