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

Username
  

Password
  





  MISRA C:2012 publication date
Posted by: david ward - 26-02-2013, 01:02 PM - Forum: Announcements - No Replies

MISRA is very pleased to announced today at Embedded World that the next edition of MISRA C Guidelines for the use of the C language in critical systems, to be known as MISRA C:2012, will be available from the MISRA webstore from 18 March 2013. Initially PDF copies will be available to purchase, with print copies available about 2 weeks later.

MISRA C:2012 extends support to the C99 version of the C language (while maintaining guidelines for C90), in addition to including a number of improvements that can reduce the cost and complexity of compliance, whilst aiding consistent, safe use of C in critical systems. Improvements, many of which have been made as a result of user feedback, include: better rationales for every guideline, identified decidability so users can better interpret the output of checking tools, greater granularity of rules to allow more precise control, a number of expanded examples and integration of MISRA AC AGC. A cross reference for ISO 26262 has also been produced.

Check back here for further details or subscribe to the MISRA mailing list to stay informed.

Print this item

  Rule 14–7–3 Example errata?
Posted by: minhyuk - 07-02-2013, 11:58 PM - Forum: 6.14 Templates (C++) - Replies (1)

See 14-7-3 Example:

a function template specialization for good_tmp1 violated ODR in tmp1.cc.

Code:
// tmp1.h
template  void good_tmp1 ( ) { }

// tmp1.cc
#include "tmp1.h"
template  void good_tmp1 ( ) { }

I think function template specialization must be forward declaration in header file.
any reason for that?

Best Regards,
Minhyuk Kwon@Suresoft technologies Incs.

Print this item

  8.7 and design for testatbility
Posted by: ggentile - 24-01-2013, 03:08 PM - Forum: 6.8 Declarations and Definitions - Replies (1)

It seems that the 8.7 rule contradict design for testability.
Infact when you have a static variabile defined at block level, right now you have no way to perform any white box testing withot changing/adding code to copy the value to a global variable.

Let me know

Giacomo

Print this item

  Rule 17.4 - array elements contained inside structure def
Posted by: sshidore - 21-01-2013, 08:08 AM - Forum: 6.17 Pointers and Arrays - Replies (1)

• MISRA C rule 17.4 says arithmetic operations shall not be performed on pointers, as they may result into referencing to non-existing addresses.
• Alternative to this is to catch a pointer being received as an argument into the respective type of an array, for e.g. catch ‘&arr’ into ‘arr[]’, and use array indexing to access its elements. This works well for pointers of basic data types.
• Problem arises in the case of accessing array elements contained by a structure.
• e.g.
struct message
{
int address;
int length;
int data[50];
}m1,m2;

• Now, the statement “source_node = m1.data[SOURCE_NODE_INDEX]” triggers this 17.4 non-compliance note.
• This happens when accessing only the array elements, and not for single variables of a structure definition.
• So the question I have is, what is the best way to access individual array elements contained inside a structure definition?

Print this item

  Application of rule 14.10 for Autogenerated code
Posted by: ssauvage - 14-01-2013, 01:49 PM - Forum: MISRA AC AGC discussions - Replies (1)

I have recently received a question from a customer using our code generation tools (embedded coder).
The code that we generate for a block (saturate block) is like this:

Code:
rtB_out = something;
if(rtB_out > maxlim) {
   rtB_out = maxlim;
}
else {
   if(rtB_out < minlim) {
      rtB_out = minlim;
   }
}

The customer asked whether the code above was MISRA compliant, in particular with respect to rule 14.10.
It is an “
Code:
if ... else { if { ... } }
” construct and very close to the “
Code:
if ... else if ...
” construct as described in the rule 14.10.
However, it can be read as a simple if being the statement in an else clause.

Personally, I find the code quite readable as it is and it is easy to check that there is no path where rtB_out is not assigned a value.
Would you recommend to have a final else in this context?

Print this item

  Issues covered by rule 3.1
Posted by: mtempest - 09-01-2013, 05:44 AM - Forum: 6.3 Documentation - Replies (1)

Hi

As I understand it, rule 3.1 is a "catch all" rule that addresses all of the implementation-defined behaviour not addressed by the other rules. However, MISRA-C:2004 does not explicitly list all of those issues, so it is not possible to tell at a glance exactly what falls under rule 3.1. This creates some difficulty determining the extent to which our static analysis software enforces the MISRA rules, and therefore also when enforcing the delta with manual review.

I could draw up a list of those issues using MISRA-C:2004 Appendix G as a guide to determining which of the issues in ISO/IEC 9899:1990 Appendix G are addressed by other rules, and seeing what is left. I could do this, but it is not a 5-minute exercise (for me) and I suspect that this work has already been done many times before now.

Has a list like that been published on the web anywhere? I've tried googling for it, but to no avail.

Kind regards
Michael

Print this item

  Rule 3-2-4 comparison with MISRA C Rule 8.9
Posted by: sarkarsaurabh_27 - 03-01-2013, 06:59 AM - Forum: 6.3 Basic concepts (C++) - Replies (1)

An identifier with external linkage shall have exactly one definition.
The test exemplar provided with MISRA C for rule 8.9 has
// mc2_0809_1.c
int32_t two_different_definitions = 1; /* Not Compliant - two definitions */
// mc2_0809_2.c
int32_t two_different_definitions = 2; /* Not Compliant - two definitions */
// mc2_0809.h
extern int32_t two_different_definitions;

But the example given in the MISRA C++ Guidelines Draft for Rule 3-2-4 is :
// file1.cpp
int32_t i = 0;
// file2.cpp
int32_t i = 1; // Non-compliant

As both the rules are some what same, but the difference in the example given is that in rule 3-2-4 no external linkage is provided. Is it an incomplete example or the rule should show violation without having an extern of the variable.

Print this item

  Dynamic memory allocation - rule 20.4
Posted by: mroczeks - 13-12-2012, 11:49 AM - Forum: 6.20 Standard Libraries - Replies (4)

Hi,

I missed discussion about new Misra C to be released.
Anyway now and then I have several questions and comments about dynamic memory allocation.

In Misra C 2004 there is only one rule (20.4) addressing dynamic memory allocation.
In my opinion it's too little. There are questions not answered by this single rule.

So the questions are:
1. Is this rule only forbiding use of malloc, calloc, realloc and free functions while leaving a room for implementation and use of prorpietary functions?

2. Is proprietary dynamic memory management allowed in any way?

3. I would like to implement my own "heap" (pool) which would allow for memory allocation on startup only and no deallocation anytime. Is this possible without violation of this rule?

In my opinion these questions should be answered in new Misra in some clearer way.

Best regards,
Szymon

Print this item

  Rule #5.1 clarification
Posted by: gs - 10-12-2012, 03:49 PM - Forum: 6.5 Identifiers - Replies (1)

Hi,
The conversation at http://www.misra.org.uk/forum/viewtopic.php?f=61&t=508 states identifiers longer than 31 characters are permitted. However, the exemplar suite suggest such identifiers are, per se, prohibited. Which is correct?

Print this item

  10.1 Non-constant value to function
Posted by: borth - 26-11-2012, 11:58 AM - Forum: 6.10 Arithmetic Type Conversions - Replies (1)

Hey,

i have a problem with these 10.1 Rule:

Code:
void foo_bar(uint32_t u32)      /* another function to do something */

void test_func(uint8_t u8)
{
   uint32_t u32Convert = (uint32_t)u8;
   ...
   foo_bar(u32Convert);      /*Error - Note 960 Violates MISRA 2004 Required Rule 10.1, Prohibited Implicit Conversion: Non-constant argument to function */
   ...
}
MISRA says that a expression, which is a function argument, shouldn't be converted to a underlying type.
But i took a 8 bit value, expand to 32bit and use this for the function. The type of u32Convert is uint32_t as it should be for the function argument of foo_bar.
Is it neccessary to know what foo_bar does with the value?

Thanks for your help!
Greetz,

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,309
» Latest member: 1fuhd
» Forum threads: 1,066
» Forum posts: 2,933

Full Statistics

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

Latest Threads
13.2 Was TC2 correctly ap...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:47 PM
» Replies: 1
» Views: 625
20.12 Does the stringific...
Forum: 8.20 Preprocessing directives
Last Post: misra-c
08-10-2026, 12:40 PM
» Replies: 1
» Views: 554
13.3 Should side effects ...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:37 PM
» Replies: 1
» Views: 428
11.6 pointer to pointer t...
Forum: 8.11 Pointer type conversions
Last Post: misra-c
08-10-2026, 12:21 PM
» Replies: 2
» Views: 1,032
What is the UTLR of -1?
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 12:15 PM
» Replies: 1
» Views: 597
10.3 Clarify if narrower ...
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 11:57 AM
» Replies: 1
» Views: 508
It 8.12 intended to be so...
Forum: 8.8 Declarations and defnitions
Last Post: misra-c
08-10-2026, 11:50 AM
» Replies: 1
» Views: 455
Rule 0.1.1 Example f4
Forum: 4.0 Language independent issues
Last Post: cgpzs
07-10-2026, 11:07 AM
» Replies: 3
» Views: 725
Rule 6-2-2 Usage of std::...
Forum: 6.6 Statements (C++)
Last Post: misra cpp
25-09-2026, 05:43 PM
» Replies: 1
» Views: 436
M5-0-4 switch over unscop...
Forum: 6.5 Expressions (C++)
Last Post: misra cpp
25-09-2026, 01:00 PM
» Replies: 3
» Views: 539