ccollins476ad commented on issue #1093: timeout/tick / int32_t vs uint32_t
URL: https://github.com/apache/mynewt-core/issues/1093#issuecomment-391782737
 
 
   That page describes something slightly different: operations on signed 
integers that result in overflow.  That is indeed undefined in the C standard.  
However, that does not apply to something like the following:
   
   ```
   uint32_t now;
   uint32_t then;
   int32_t delta;
   
   // [...]
   delta = now - then;
   ```
   
   In this excerpt, all operations are performed on unsigned integers.  The 
resulting unsigned integer is then implicitly converted to a signed integer via 
assignment.  *Conversion* of out-of-range values to a signed integer is 
implementation defined; *arithmetic* on signed integers resulting in overflow 
is undefined.
   
   From the c11 draft specification (for all intents and purposes it is 
identical to the official c11 standard, it is just free instead of costing 
hundreds of dollars): http://www.iso-9899.info/n1570.html; this is documented 
in section 6.3.1p3.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to