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

Re: [PATCH] Trivial warning fix for imap-send.c

From
Horst von Brand <vonbrand@inf.utfsm.cl>
Date
Mar 13, 2006, 04:14 UTC
Message-ID
<200603130414.k2D4EXcX011651@laptop11.inf.utfsm.cl>
In-Reply-To
<peff@peff.net>
Jeff King <peff@peff.net> wrote:
[...]
Show 7 quoted lines
> A void pointer is guaranteed to be able to hold any type of pointer
> (either char * or struct foo * or whatever). The declaration of malloc
> indicates a return of void *. On a platform where it matters, the
> compiler generates code so that 
>   struct foo *bar = malloc(100);
> converts the void * pointer into the correct size (in the same way that
> assigning between differently sized integers works).
Right.
Show 6 quoted lines
> This breaks down with variadic functions, which have no typing
> information. So doing this:
>   execl("foo", "bar", my_struct_foo);
> doesn't give the compiler a chance to do the implicit cast and you get
> subtle breakage (in the same way that you would if you passed a long to
> a variadic function expecting a short).
It just passes 3 "void *"'s, and casts back. What is so strange?
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
Previous: Jeff KingNext: Linus Torvalds
Message 3 of 5 in “Re: [PATCH] Use explicit pointers for execl...() sentinels.”
  1. Horst von BrandMar 13, 2006
  2. [OT] Re: [PATCH] Use explicit pointers for execl...() sentinels.Jeff King, Mar 14, 2006
  3. Horst von BrandMar 13, 2006
  4. Linus TorvaldsMar 13, 2006
  5. Horst H. von BrandDec 5, 2006

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.