logoalt Hacker News

jjmarr • today at 6:29 PM • 0 replies • view on HN

> not guaranteed but allowed by the language and widely implemented

Ome can make it guaranteed (assuming Foo is an aggregate) by writing:

    Foo make_foo() {
      return Foo{.blah = 7};
    }
This guarantees initialization happens at the end of the function, since you are returning a pure rvalue. Generally a good style rule to adopt and no annotations needed.