Addition of floats allocates memory in not fully qualified struct

This is a type instability. The compiler doesn’t know the type of bar.foo at compile time, so it has store it in a heap-allocated “box” with a type tag that is inspected at runtime.

See Performance Tips: Avoid fields with abstract type.

4 Likes