Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MISRA-C:2012 5.4 deviation procedure
#1
For clarification, at 5.4 deviation procedure in MISRA-C:2012,
There are codes, like this

#define PORT (* (volatile unsigned char * )0x002)
PORT = 0x010u;

I try to compile and go like this.
// file misrac-5-4.c
#include "misra_c.h" // #include and type definitions.
#define PORT (* (volatile unsigned char * )0x002)
int main(void){
printf(" PORT = %x \n", (unsigned int) &PORT);
PORT = 0x010u;
return printf("End of File misrac-5-4.c: Deviation procedure\n");
}
// file end
command is
cc -std=c99 -Wall misrac-5-4.c

There are no error and no warning.

The results are
PORT = 2
Segmentation fault: 11

This in intended behavior? or
Are there any good implementation?

I use Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.1.0 Thread model: posix.

By the way, I try to compile all examples of MISRA-C:2012.

Are there any good place about sample codes without of the rules and directories.
<t>Dr. OGAWA Kioshi<br/>
@kaizen_nagoya</t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)