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

Re: [RFC PATCH 1/2] Replace memset(0) with static initialization where possible

From
Nicolas Pitre <nico@cam.org>
Date
Oct 9, 2008, 21:12 UTC
Message-ID
<alpine.LFD.2.00.0810091701380.26244@xanadu.home>
In-Reply-To
<CqZt8k7g-Uov2ItkgRw6K65RC0ee37ZAckIrbwPLNwDiaHtigtevnA@cipher.nrlssc.navy.mil>
On Thu, 9 Oct 2008, Brandon Casey wrote:
Show 8 quoted lines
> Nicolas Pitre wrote:
> > So when claiming flexibility for the compiler to better optimize things, 
> > please make sure this is really what is happening through assembly dump 
> > inspection.
> 
> I didn't claim the compiler _would_ do a better job at optimizing if
> memset wasn't used (though my expectation is that it would do no worse,
> and I don't have assembly dumps to back that up).
My point is that such expectation might not always be true.
> I suggested it could
> give the compiler more flexibility. In some strange way you seem to
> agree with me and have given 3 examples of ways that compilers may
> optimize static initialization. :)
Actually the first example was a case of making things worse.
Show 6 quoted lines
> Anyway, this is a nothing patch. There is no functional change.
> If readability is not improved, it is not worth applying. Of course, I
> don't plan on scanning through and converting all of the existing assignments
> which use { 0, } to use memset. I find a single step declaration/initialization
> simpler. Not sure why that seems to be the case in the git source for simple
> variables but not structures.
... because of that possible gcc making things worse I mentioned.
Nicolas
Previous: Brandon Casey
Message 6 of 6 in “Replace memset(0) with static initialization where possible”
  1. 1/2 Replace memset(0) with static initialization where possibleBrandon Casey, Oct 9, 2008
  2. Shawn O. PearceOct 9, 2008
  3. Brandon CaseyOct 9, 2008
  4. Nicolas PitreOct 9, 2008
  5. Brandon CaseyOct 9, 2008
  6. Nicolas PitreOct 9, 2008

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.