Johannes Sixt <> writes:

> Am 8/20/2012 12:36, schrieb Joachim Schmitz:
>> int var = var;
>> char *othervar = othervar;
>> ... 
>> What is the reason for using that self-init stuff? I don't think it is
>> really portable, is it?
> It is used to avoid "var may be used uninitialized" warnings for some
> compilers. Officially (according to the C standard), it is undefined
> behavior. But I've observed considerable resistance by Junio to fix this
> properly.

I had resisted

        -       int foo = foo;
        +       int foo = 0;

in the past.  If some compiler is not seeing that "foo" is never
used uninitialized, such a compiler will generate an unnecessary
initialization, so it is not a _proper_ fix anyway (in fact, I do
not think a proper fix exists, short of simplifying the code so that
less sophisticated compilers can see that "foo" is never used

So, no, I never resisted a "proper" fix.  I resisted swapping an
unsatisfactory workaround with another.

Between the two unsatisfactory workarounds, the latter (explicit
and unnecessary assignment to an innocuous value) is lessor of two
evils, so I do not particularly mind it, though.  Indeed, I think
more recent history shows that we have such changes.

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to