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

C standard compliance?

From
David Kastrup <dak@gnu.org>
Date
Jan 29, 2014, 20:33 UTC
Message-ID
<87iot25y0r.fsf@fencepost.gnu.org>

Hi, I am wondering if I may compare pointers with < that have been created using different calls of malloc.

The C standard does not allow this (inequalities are only allowed for pointers into the same structure) to allow for some cheapskate sort of comparison in segmented architectures.

Now of course being able to _sort_ pointers also allows to _collate_ them. It totally does not matter just _what_ their ordering relation is as long as it yields to a sorting function (namely obeys some basic relations).

The question is whether this kind of undefined behavior (which almost never is implemented in unexpected ways) is frowned upon in the Git codebase or not.

-- 
David Kastrup
Next: Junio C Hamano
Message 1 of 6 in “C standard compliance?”
  1. David KastrupJan 29, 2014
  2. Junio C HamanoJan 29, 2014
  3. David KastrupJan 29, 2014
  4. Philip OakleyJan 29, 2014
  5. brian m. carlsonJan 29, 2014
  6. David KastrupJan 30, 2014

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.