Originally Posted by
@nthony
So generally, is this a good, bad or neutral thing?
None of these. It's a language feature. If you use it well, it's a good thing. If you abuse it, it's a bad thing. If you use it in a way that makes little difference one way or the other .....
Personally, I find it a good thing, but I tend to use it in C++ rather than in C code. And in C++ it is a good feature, as it allows control over when an object is created. As long as I don't abuse the feature
Originally Posted by
@nthony
Should I feel guitly that my compiler lets me "get away" with this? Or should I feel justified in using a newer C standard?
That's up to you. If you only ever use compilers that support this feature, and don't give your code to someone who uses different compilers, there is no need to feel guilty about using this feature. If, however, there is any potential your code will be ported to a compiler that doesn't use this feature, then you should never use it.
Incidentally, it is quite easy to get the same control over lifetime of variables, even if your compiler does not support this feature. For example;
Code:
int main()
{
/* assume we have a compiler that supports this */
function();
int x = some_result_we_could_not_compute_before_calling_function();
some_other_function_call(x);
}
is functionally equivalent to;
Code:
int main()
{
/* assume we have vanilla C 89 compiler */
function();
{
int x = some_result_we_could_not_compute_before_calling_function();
some_other_function_call(x);
}
}
In fact, if you look at behaviour of some older compilers that converted early versions of C++ into C (where the C compiler didn't support this behaviour), you will find they did this sort of simple translation.