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

Re: [PATCH v3] do not depend on signed integer overflow

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Oct 5, 2010, 07:26 UTC
Message-ID
<AANLkTimdaghq5_vcb+7Anh_05oLJUbZuNXU47YWdBudq@mail.gmail.com>
In-Reply-To
<alpine.LFD.2.00.1010050012490.3107@xanadu.home>
On Tue, Oct 5, 2010 at 6:17 AM, Nicolas Pitre <nico@fluxnic.net> wrote:
Show 13 quoted lines
> On Tue, 5 Oct 2010, Erik Faye-Lund wrote:
>
>> Signed integer overflow is not defined in C, so do not depend on it.
>>
>> This fixes a problem with GCC 4.4.0 and -O3 where the optimizer would
>> consider "consumed_bytes > consumed_bytes + bytes" as a constant
>> expression, and never execute the die()-call.
>>
>> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
>
> I like this.  Please also fix the similar case in
> builtin/pack-objects.c:write_one().
>

Thanks for pointing that one out. For some reason GCC didn't warn about that instance - perhaps it's optimizer missed the case due to going through that pointer?

I've just resent a version with that fix-up.
Previous: Nicolas Pitre
Message 4 of 4 in “do not depend on signed integer overflow”
  1. do not depend on signed integer overflowErik Faye-Lund, Oct 4, 2010
  2. Jeff KingOct 5, 2010
  3. Nicolas PitreOct 5, 2010
  4. Erik Faye-LundOct 5, 2010

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.