git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [bug?] checkout -m doesn't work without a base version

From
MSMichael Schubert <mschub@elegosoft.com>
Date
Dec 15, 2011, 10:11 UTC
Message-ID
<4EE9C7D9.8020407@elegosoft.com>
In-Reply-To
<buoipli8nzy.fsf@dhlpc061.dev.necel.com>
On 12/15/2011 05:20 AM, Miles Bader wrote:
Show 20 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>>> builtin/checkout.c: In function ‘cmd_checkout’:
>>> builtin/checkout.c:210:5: warning: ‘mode’ may be used uninitialized
>>> in this function [-Wuninitialized]
>>> builtin/checkout.c:160:11: note: ‘mode’ was declared here
>>
>> Isn't this just your gcc being overly cautious (aka "silly")?
>>
>> The variable "mode" is assigned to when we see an stage #2 entry in the
>> loop, and we should have updated threeway[1] immediately before doing so.
>> If threeway[1] is not updated, we would have already returned before using
>> the variable in make_cache_entry().
> 
> Maybe that is actually guaranteed (I dunno), but it's certainly not
> obvious from the code here, even to a human... any guarantee would
> have to come from external invariants that the compiler doesn't know
> about.
> 
> Given that, I think it's a fair warning, certainly not "silly."  This
> aspect of the code doesn't seem easy to understand...

Silly or not: That's what gcc 4.6.x is warning about with -Wuninitialized (-Wall) set - I didn't set any additional options, just plain `make all`.

Previous: Miles BaderNext: Andreas Schwab
Message 12 of 15 in “[bug?] checkout -m doesn't work without a base version”
  1. Pete HarlanDec 4, 2011
  2. Junio C HamanoDec 5, 2011
  3. Pete HarlanDec 7, 2011
  4. Junio C HamanoDec 8, 2011
  5. Pete HarlanDec 12, 2011
  6. Junio C HamanoDec 12, 2011
  7. t/t2023-checkout-m.sh: fix use of test_must_failÆvar Arnfjörð Bjarmason, Dec 20, 2011
  8. Junio C HamanoDec 20, 2011
  9. Michael SchubertDec 14, 2011
  10. Junio C HamanoDec 14, 2011
  11. Miles BaderDec 15, 2011
  12. Michael SchubertDec 15, 2011
  13. Andreas SchwabDec 15, 2011
  14. Junio C HamanoDec 15, 2011
  15. Ramsay JonesDec 16, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.