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

Re: New-ish warning in refs.c with GCC (at least 11.2) under -O3

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2021, 23:23 UTC
Message-ID
<xmqqwnl5ujxw.fsf@gitster.g>
In-Reply-To
<YZQhLh2BU5Hquhpo@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> +	/*
> +	 * Should be a noop per the ALLOWED_FLAGS check above, but this
> +	 * is necessary to work around a problem with some versions of
> +	 * "gcc -O3 -Wnonnull", which otherwise thinks that you can have the
> +	 * flag set with a NULL new_oid.
> +	 */
> +	flags &= ~REF_HAVE_OLD | REF_HAVE_NEW;
Are you missing parentheses around ~(OLD|NEW)?
Show 8 quoted lines
>  	flags |= (new_oid ? REF_HAVE_NEW : 0) | (old_oid ? REF_HAVE_OLD : 0);
>  
>  	ref_transaction_add_update(transaction, refname, flags,
>
> I do find it interesting that gcc really _is_ convinced that those flags
> can be set coming in, since clearing them makes the problem go away.
> ...
> Reading over the code, it all looks OK. And that size is...weirdly huge.

The original bug is really annoying and this looks even worse. Hopefully it won't come down from experimental to more stable tracks before they are corrected.

Previous: Jeff KingNext: Jeff King
Message 5 of 6 in “New-ish warning in refs.c with GCC (at least 11.2) under -O3”
  1. Ævar Arnfjörð BjarmasonNov 15, 2021
  2. Jeff KingNov 15, 2021
  3. Taylor BlauNov 16, 2021
  4. Jeff KingNov 16, 2021
  5. Junio C HamanoNov 18, 2021
  6. refs: work around gcc-11 warning with REF_HAVE_NEWJeff King, Nov 19, 2021

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.