After enabling lto in one of my projects the compiler started to throw warnings for lto violations at me. After a bit of testing it boils down to this construct.
typedef struct {
typedef struct {
} test_t;
std::vector<test_t> t;
} test2_t;
Once I change it to
struct test2_t {
typedef struct {
} test_t;
std::vector<test_t> t;
};
or
typedef struct {
typedef struct {
} test_t;
test_t t;
} test2_t;
the warning goes away but I don't really understand why. My guess is that it treats the anonymous struct as different types in different files, but I would not expect a warning since it is a common use case. Note that it does not make a difference if I change the inner typedef but leave the outer on in place. It also does not matter whether test_t contains members or not.
- What's the reason for this warning?
- Is this behaviour expected?
- Might this be an STL error, since it works fine without vector?