Created attachment 29377 [details]
Compile with -flto -O2
/tmp/cce3xw28.ltrans0.ltrans.o:cce3xw28.ltrans0.o:function main: error: undefined reference to 'bar'
Strict aliasing is effectively turned off for LTO.
(In reply to comment #1)
> Strict aliasing is effectively turned off for LTO.
That's not true. It's just weakened to the extend to make structurally
equivalent types have the same alias sets. In this case struct S and
struct T are aliasing.
So indeed this works as designed.