
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
53 lines
1.8 KiB
Plaintext
53 lines
1.8 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The type of an integer is dependent on a complex combination of factors including:
|
|
|
|
* The magnitude of the constant;
|
|
* The implemented sizes of the integer types;
|
|
* The presence of any suffixes;
|
|
* The number base in which the value is expressed (i.e. decimal, octal or hexadecimal).
|
|
|
|
For example, the value 0x8000 is of type ``++unsigned int++`` in a 16-bit environment, but of type (``++signed++``) ``++int++`` in a 32-bit environment.
|
|
|
|
Note:
|
|
|
|
* Any value with a "U" suffix is of unsigned type;
|
|
* An unsuffixed decimal value less than 2^31 is of signed type.
|
|
|
|
But:
|
|
|
|
* An unsuffixed hexadecimal value greater than or equal to 2^15 may be of signed or unsigned type;
|
|
* For C90, an unsuffixed decimal value greater than or equal to 2^31 may be of signed or unsigned type.
|
|
|
|
In {cpp}, if an overload set includes candidates for an ``++unsigned int++`` and an ``++int++``, then the overload that would be matched by 0x8000 is therefore dependent on the implemented integer size. Adding a "U" suffix to the value specifies that it is unsigned.
|
|
|
|
|
|
== Resources
|
|
|
|
* MISRA C:2004, 10.6 - A "U" suffix shall be applied to all constants of unsigned type.
|
|
* MISRA {cpp}:2008, 2-13-3 - A "U" suffix shall be applied to all octal or hexadecimal integer literals of unsigned type.
|
|
* MISRA C:2012, 7.2 - A "u" or "U" suffix shall be applied to all integer constants that are represented in an unsigned type.
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Add a "U" suffix to this constant, to make it explicitly "unsigned".
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== is duplicated by: S816
|
|
|
|
=== on 23 Oct 2014, 14:08:57 Samuel Mercier wrote:
|
|
Requires knowledge of size of the fundamental types.
|
|
|
|
endif::env-github,rspecator-view[]
|