lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #51447] Sequence number comparisons invoke undefined b


From: Stian Sebastian Skjelstad
Subject: [lwip-devel] [bug #51447] Sequence number comparisons invoke undefined behavior
Date: Wed, 12 Jul 2017 03:23:32 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

Follow-up Comment #2, bug #51447 (project lwip):

typecasting between s32_t and u32_t is not undefined behaviour. On (almost
all) systems, CPU work in 2nd compliments and the only differences about u32_t
and s32_t are which branch instructions or which comparison instruction to
use. 

The only situations where unwanted results might occur is when going from
16bit into 32bit. Example: u16_t into s32_t will cause numbers to not be
signed extended (-1 will become 0x0000ffff for example).

The current macro will for example detect sequence number 0x00000004 to come
after 0xfffffffe, since it only looks at the delta, ignoring that it has
wrapped around zero.


In which situation does the current macro fail to give the correct result? 



(file #41185)
    _______________________________________________________

Additional Item Attachment:

File name: u32.c                          Size:0 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?51447>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]