Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





  MISRA-C:2012 5.4 deviation procedure
Posted by: ogawa.kiyoshi - 16-04-2014, 02:17 AM - Forum: General Questions - Replies (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.

Print this item

  Essential Type of parenthesised expression
Posted by: misra-c - 11-04-2014, 07:47 AM - Forum: 8.10 The essential type model - Replies (1)

What is the essential type of a parenthesised expression?

For example: ( 3 U ) has a standard type of "unsigned int". Is the essential type of the parenthesised expression "unsigned int" or "unsigned char"

Print this item

  MISRA C:2012 addenum typo
Posted by: Lundin - 04-04-2014, 02:10 PM - Forum: MISRA C:2004 to MISRA C:2012 migration - Replies (1)

I found a typo in the MISRA C:2012 addenum.

Page 6, rule 2004:19.4 compared with 2012:20.4

Quote:Rule 14.6 requires that a macro with more than 1
statement does not get expanded in an iteration or
selection statements.

Rule 14.6 does not exist. It should be Rule 15.6 "The body of an iteration statement..." /--/ "...should be a compound statement".

Print this item

  Questions about Rule 2.1
Posted by: tsukukazu - 01-04-2014, 09:42 AM - Forum: 8.2 Unused code - Replies (4)

In rule 2.1 sample code,

default:
{
/*
* This default will only be ......
* holds a value that is not ......
*/
}

The comments here,there are not written neither compliant nor non-compliant.
But I have understood to be compliant from the comment.
Is it correct?

Best Regards.

Print this item

  A Question for Rule8.5
Posted by: KumikoItoh - 01-04-2014, 01:12 AM - Forum: 8.8 Declarations and defnitions - Replies (1)

Hello

I have a question for the Rule8.5 etc.

The Rule8.5 in MISRAC_2004 was deleted in MISRAC_2012.

In MISRA C:2012 RuleMappings,
Rule8.5's description is
[The problems associated with --- dealt with by other rules].

I think that "other rules" means "Rule8.4, Rule8.5, and Rule8.6 in MISRAC 2012".

Is my opinion correct?

Please teach me your idea and rule numbers.

Best Regards,
Kumiko Itoh

Print this item

  I comply with which rules
Posted by: bschoi1984 - 27-03-2014, 01:09 PM - Forum: General Questions - Replies (2)

I have mixed feeling for comply with MISRA-C 2004 because I use Autocode generator such as TargetLink and I think it is reasonable that they make efforts to comply with MISRA-AC such as MISRA-AC ACG, MISRA-AC TL and MISRA-AC SLSF.

So I don’t know which stand (MISRA-C or MISRA-AC) I have to conform to.
I want to know which standard the people using hand-coding comply with and the people using MBD(Model-based development with AutoCode Generator) comply with.
If possible, please give me some opinions

Print this item

  Rule 11.3 Access to registers or memory
Posted by: barbara.seyfarth - 27-03-2014, 10:31 AM - Forum: 6.11 Pointer Type Conversions - Replies (2)

A cast should not be performed between a pointer type and an integral type, this casts from type "unsigned int" to "uint32_t volatile *" (MISRA C 2004 rule 11.3)
In two cases this error occurs on my system (ARM Cortex M3 with IAR workbench and MISRA check from IAR):
1. Access to registers.
2. Access to RAM (during a cyclic RAM test).

Is there any way conform to MISRA C2004 for the following code?

Code:
register uint32_t address; /* during the critical section no RAM access other than the test access may occur */
    register uint32_t pattern;

    ...
    *(volatile uint32_t *)address = pattern;

Print this item

  Out of date link
Posted by: keith.collyer - 20-03-2014, 03:18 PM - Forum: General Questions - Replies (1)

Who needs to be contacted about an inaccurate link on the Links page of the web site (http://www.misra.org.uk/Links/tabid/63/Default.aspx)? Telelogic was acquired by IBM in 2008, so this entry should now read "IBM Rational" and the link should be http://www-01.ibm.com/software/rational/.

Thanks

Print this item

  MISRA rule 20.1 and 20.2
Posted by: VRK - 14-03-2014, 06:53 PM - Forum: 6.20 Standard Libraries - Replies (2)

20.1 (req): %s: Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined.
20.2 (req): %s: The names of standard library macros, objects and functions shall not be reused.

As per the rule 20.1, Reserved identifiers should not be defined, redefined or undefined.
I am getting the violation of MISRA 20.2 for the below example:

For the declaration,
int for;
'for' is the reserve identifier. It is re-defined as variable declaration and it is not used in any standard library.
Hence it should violates the MISRA rule 20.1 and not MISRA rule 20.2.

Please explain the difference between MISRA 20.1 and 20.2 rules with suitable examples.

Print this item

  6.2 and switch/case labels
Posted by: dreser - 11-03-2014, 04:44 PM - Forum: 6.6 Types - Replies (1)

I'm not 100% sure on the interpretation of rule 6.2 when it comes to using "unsigned char" values as labels for switch case.

Example:

Code:
const uint8_t CONSTANT_ONE = 12U;
const uint8_t CONSTANT_TWO = 34U;

uint8_t value = foo();

switch (value)
{
case CONSTANT_ONE:
  [...]
   break;
case CONSTANT_TWO:
  [...]
   break;
default:
  [...]
   break;
}

For each of the "case " lines PC-lint (from V9.00j on) complains about a "Disallowed use of non-numeric value in a case label".
I would have considered defining and using the contants as "storage and use of numeric values" as described in 6.2.
I also can not find a similar limitation in MISRA-C 2012. Though I might not have looked deeply enough as I only have it in printed form.

Thanks for any feedback you might have on this.

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,205
» Latest member: vietc93
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

Online Users
There are currently 93 online users.
» 0 Member(s) | 90 Guest(s)
Bing, Google, UptimeRobot

Latest Threads
Rule 7.0.5, example non-c...
Forum: 4.7 Standard conversions
Last Post: cgpzs
17-04-2025, 12:10 PM
» Replies: 0
» Views: 173
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 303
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 286
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 193
Rule 8.2.8 - why aren't a...
Forum: 4.8 Expressions
Last Post: misra cpp
28-03-2025, 01:05 PM
» Replies: 1
» Views: 214
Typo in Appendix C of MIS...
Forum: 8.10 The essential type model
Last Post: Yordan Naydenov
17-03-2025, 02:58 PM
» Replies: 0
» Views: 168
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 267
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 215
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 271
A8-4-5: Should have an ex...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
21-02-2025, 12:58 PM
» Replies: 3
» Views: 701