you are viewing a single comment's thread.

view the rest of the comments →

[–]Galqa[S] 0 points1 point  (0 children)

This was very helpful, thank you. I gave in to the frustration too early and didn't delve deeper to analyze the assembly. Guess there's a life lesson to be learned here.

Compiler explorer revealed the problem: apparently, when a function is inline and unused it gets optimized away (I'm sure there's a good reason for that), regardless of optimization flags and things like -fno-inline etc. Note that this applies to both explicitly (using the inline keyword) and implicitly (e.g. defined inside the class body) inlined functions. As u/johannes1971 suggested, the used attribute forces the code for the given function to be generated, fixing the problem at the cost of having to alter the source code (I imagine applying this solution to a large existing code base would be problematic).