26-09-2007, 01:41 PM
While C considers plain char, signed char and unsigned char to be integral types, MISRA-C considers plain char to be a distinct underlying type which is used only for \"character\" data.
From your examples,
This breaks rule 6.2.
This breaks 10.1.
From your examples,
Code:
unsigned int c = 'x'; /* Not a \"conversion from signed to unsigned\" violation? */
This breaks rule 6.2.
Code:
void foo(int x) {
unsigned int c = x; /* Violation: conversion from signed to unsigned. */
}
This breaks 10.1.
Posted by and on behalf of the MISRA C Working Group