Yes, it's easy to find situations where the optimizer cannot optimize code. This doesn't discount the fact that in many cases it can.
I can't imagine a situation where the initialization cost in this type of code would be significant though. The overhead of calling the function, and the sub-function are probably more. And if there's any actual memory access involved, the pipelining of the CPU may render the init negligable.
That code also has the problem of a person being unable to determine whether it is correct. Without looking at the documentation for sys_fcn, you cannot tell if you should have initalized that variable or not.
As I said, in the cases where this is truly a cost problem (and they do exist), you could annotate it:
int a = undefined;
Or something like that.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yes, it's easy to find situations where the optimizer cannot optimize code. This doesn't discount the fact that in many cases it can.
I can't imagine a situation where the initialization cost in this type of code would be significant though. The overhead of calling the function, and the sub-function are probably more. And if there's any actual memory access involved, the pipelining of the CPU may render the init negligable.
That code also has the problem of a person being unable to determine whether it is correct. Without looking at the documentation for
sys_fcn
, you cannot tell if you should have initalized that variable or not.As I said, in the cases where this is truly a cost problem (and they do exist), you could annotate it:
Or something like that.