[previous] MISRA-C:2004  Rule  3.1:  (Required) [next] All usage of implementation-defined behaviour shall be documented.
This rule requires that any reliance on implementation-defined behaviour, which is not specifically addressed by other rules, shall be documented, for example by reference to compiler documentation. Where a specific behaviour is explicitly covered in another rule, only that specific rule needs to be deviated if required. See ISO/IEC 9899:1990 Appendix G [2] for a complete list of these issues.

Example Code:


/* PRQA S 2983,3203,3205 ++ */
#include <stdlib.h>
#include "misra.h"
#include "m2cmex.h"

#define MSTR "ABC$"                             /* Implementation Defined */

extern S16 test_0301( void )
{
   /* Non portable comment - $$$ */             /* Implementation Defined */
   wchar_t  wch = L'ab';                        /* Implementation Defined */
   PC bufc[] = "abc$";                          /* Implementation Defined */
   S16 sra;
   S16 srb;
   S16 sia;
   struct x;
   struct x * ptr;


   ptr = (struct x*)&sra;                       /* Implementation Defined */


   if (s16a > 0x6000)
   {
       s16r = s16a << 3;                        /* Implementation Defined */
   }

   s16b = s16a << 3;                            /* Implementation Defined */

   s16c = 0x7654 << 3;                          /* Implementation Defined */

   sia = 'ab';                                  /* Implementation Defined */

   return 0;
}


QAC messages that encompass this guideline:

0202 [I] '-' character in '[]' conversion specification is implementation defined.
0284 [I] Multiple character constants have implementation defined values.
0285 [I] Character constant contains character which is not a member of the basic source character set.
0286 [I] String literal contains character which is not a member of the basic source character set.
0287 [I] Header name contains character which is not a member of the basic source character set.
0288 [I] Source file '%s' has comments containing characters which are not members of the basic source character set.
0289 [I] Source file '%s' has preprocessing tokens containing characters which are not members of the basic source character set.
0292 [I] Source file '%s' has comments containing one of the characters '$', '@' or '`'.
0299 [I] Source file '%s' includes #pragma directives containing characters which are not members of the basic source character set.
0303 [I] Cast between a pointer to volatile object and an integral type.
0305 [I] Cast between a pointer to function and an integral type.
0306 [I] Cast between a pointer to object and an integral type.
0308 Non-portable cast involving pointer to an incomplete type.
0581 [I] Floating-point constant may be too small to be representable.
0634 [I] Bit-fields in this struct/union have not been declared explicitly as unsigned or signed.
0878 Using wide character or string literals.
2850 Constant: Implicit conversion to a signed integer type of insufficient size.
2851 Definite: Implicit conversion to a signed integer type of insufficient size.
2852 Apparent: Implicit conversion to a signed integer type of insufficient size.
2853 Suspicious: Implicit conversion to a signed integer type of insufficient size.
2855 Constant: Casting to a signed integer type of insufficient size.
2856 Definite: Casting to a signed integer type of insufficient size.
2857 Apparent: Casting to a signed integer type of insufficient size.
2860 Constant: Implementation-defined value resulting from left shift operation on expression of signed type.
2861 Definite: Implementation-defined value resulting from left shift operation on expression of signed type.
2862 Apparent: Implementation-defined value resulting from left shift operation on expression of signed type.
2890 Constant: Negative value implicitly converted to an unsigned type.
2895 Constant: Negative value cast to an unsigned type.


Related rules:

Rule  6.4 Bit fields shall only be defined to be of type unsigned int or signed int.
Rule  11.3 A cast should not be performed between a pointer type and an integral type.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents