![]() |
|
What is the UTLR of -1? - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21) +---- Forum: 8.10 The essential type model (https://forum.misra.org.uk/forumdisplay.php?fid=165) +---- Thread: What is the UTLR of -1? (/showthread.php?tid=1772) |
What is the UTLR of -1? - Loïc - 09-06-2026 I'm attempting to determine the essential type of the following expression: Code: (unsigned short)1 - (unsigned short)2This is a operation subject to arithmetic conversion (D.7.9), both operands are essentially unsigned, and the expression is an integer constant expression, so according to item 4.1, the essential type of the result is the UTLR of the result. However, the result is a signed integer with the value -1. The following program demonstrates this: Code: #include <stdio.h>So we have to compute the UTLR of a negative value, which is not defined. Is there an error in my reasoning, or is this a limitation in the essential type system? RE: What is the UTLR of -1? - misra-c - 08-10-2026 (09-06-2026, 09:36 AM)Loïc Wrote: I'm attempting to determine the essential type of the following expression: From a C language perspective, integer promotion will be in effect here, so the result is an int with the value of -1 This has highlighted a gap in the UTLR definition, which the MISRA C WG will consider [ID: 480 applies] |