https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114372
Bug ID: 114372
Summary: Confusing ODR warning with different typedefs
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: sjames at gcc dot gnu.org
Target Milestone: ---
a.cxx:
```
#define X265_DEPTH 10
#include "c.h"
struct x265_analysis_distortion_data a;
```
b.cxx:
```
#define X265_DEPTH 1
#include "c.h"
struct x265_analysis_distortion_data b;
int main() {}
```
c.h:
```
#include <stdint.h>
#if X265_DEPTH < 10
typedef uint32_t sse_t;
#else
typedef uint64_t sse_t;
#endif
struct x265_analysis_distortion_data {
sse_t* ctuDistortion;
};
```
```
$ g++ a.cxx b.cxx -flto -Werror=odr -Werror=lto-type-mismatch
c.h:9:8: error: type ‘struct x265_analysis_distortion_data’ violates the C++
One Definition Rule [-Werror=odr]
9 | struct x265_analysis_distortion_data {
| ^
c.h:9:8: note: a different type is defined in another translation unit
9 | struct x265_analysis_distortion_data {
| ^
c.h:10:17: note: the first difference of corresponding definitions is field
‘ctuDistortion’
10 | sse_t* ctuDistortion;
| ^
c.h:10:17: note: a field of same name but different type is defined in another
translation unit
10 | sse_t* ctuDistortion;
| ^
lto1: some warnings being treated as errors
lto-wrapper: fatal error: g++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
error: lto-wrapper failed
collect2: error: ld returned 1 exit status
```
It would be nice if we included the sse_t typedef in the output.