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

Username
  

Password
  





  MISRA C:2012 AMD4 released
Posted by: david ward - 24-03-2023, 12:56 AM - Forum: Announcements - No Replies

MISRA C:2012 Amendment 4 (which completes addition of support for C11/C18 language features) is now available as a free download from the "Resources" section of this Bulletin Board.

Looking to the future we will shortly release a consolidated version (to be known as MISRA C:2023) rolling up the recent amendments and technical corrigenda. We will make a further announcement when this is available for purchase.

Print this item

  MISRA C:2012 AMD4
Posted by: david ward - 15-03-2023, 04:16 PM - Forum: MISRA resources - Replies (2)

We are pleased to announce the publication of MISRA C:2012 Amendment 4 (MISRA C:2012 AMD4). This document completes the additional updates for ISO/IEC 9899:2011/2018 with consideration of new C11/C18 features.

This amendment is intended to be used with MISRA C:2012 (Third Edition, First Revision) as revised and amended by:

  • MISRA C:2012 Technical Corrigendum 2,
  • MISRA C:2012 Amendment 2, and
  • MISRA C:2012 Amendment 3.

This amendment is also compatible with MISRA C:2012 (Third Edition) as revised and amended by:

  • MISRA C:2012 Technical Corrigendum 1,
  • MISRA C:2012 Technical Corrigendum 2,
  • MISRA C:2012 Amendment 1,
  • MISRA C:2012 Amendment 2, and
  • MISRA C:2012 Amendment 3.



Attached Files
.pdf   MISRA C 2012 AMD4.pdf (Size: 1.39 MB / Downloads: 69)
Print this item

  Are Memory Pools allowed by MISRA-C?
Posted by: jpature - 14-03-2023, 02:23 PM - Forum: 7.4 Code design - Replies (3)

Hi,

Would a memory pool (to handle a variable number of objects) based on a statically allocated chunk of memory be MISRA C compliant ? Or would it be banned because considered as dynamic allocation ?

Thanks.

Print this item

  Suggestions for a MISRA-C-2012-compliant compression library?
Posted by: philCryo - 07-03-2023, 02:41 AM - Forum: General Questions - No Replies

Hi all,

Not sure which forum in which to post this.  Any suggestions for a MISRA-C-2012-compliant compression library?  Everything I'm checking has oodles of "Required" rule violations.

Print this item

  Rule 6-5-2: Non-Compliant Example Clarification
Posted by: vapdrs - 09-02-2023, 05:36 PM - Forum: 6.6 Statements (C++) - Replies (1)

I am looking for some clarification on the first non-compliant example for Rule 6-5-2, and the overall definition of a loop-counter, which as part of its definition states it must be,

Quote:an operand to a relational operator in condition


Where relational operator is defined in Rule 4-5-2, 4-5-3, and §5.9 as <, >, <=, and >=.

In the non-compliant example
Code:
for ( i = 1; i != 10; i += 2 ) // Non-compliant

The variable i is clearly considered a loop-counter because the subject of Rule 6-5-2 is a loop-counter. I am confused as to how could i could be considered a loop-counter though, because it is not an operand to a relational operator in the for loop condition.

Moreover, if a loop-counter is defined as necessarily being an operand to a relational operator, then the point of Rule 6-5-2 is called into question. The only thing it could be applied to is when a variable is used as an operand to a relational operator (making it a loop-counter) and another expression in the conditions like,

Code:
for ( i = 1; i != 10 && i > 0 ; i += 2 ) // Non-compliant

Which is helpful for some bad behavior, but will clearly miss some fairly obvious bad behavior, like the original non-compliant example.

Tangentially related the definition of loop-counter contains a note explicitly saying that iterators are also valid as a loop-counter. However, this note would be odd, since typically when using STL iterators in loops equality operators are used and not relational operators. So Rule 6-5-1 would flag the following as non-compliant, even though it is a common idiom.

Code:
for (auto it = container.begin(); it != container.end(); ++it )

Print this item

  A3-9-1 - example with plain 'char' type
Posted by: mstaron - 08-02-2023, 08:00 AM - Forum: AUTOSAR C++:2014 rules - Replies (2)

The A3-9-1 rule recommends to use integer types from <cstdint>, indicating the size and signedness, but the plain 'char' type does not have corresponding type in this library. It is possible to replace only explicit signed or unsigned 'char' types.

The example in A3-9-1 shows the declaration of the plain 'char' type as non-compliant. I understand that in this case the 'i6' variable is initialized by numerical value, so its type should be changed to int8_t. However, this is a different problem that is non-compiant with Rule M5-0-11 "The plain char type shall only be used for the storage and use of character values.". The plain 'char' type is used in AUTOSAR documentation in cases which are marked as compliant (for example Rule A5-1-1). I suppose that A3-9-1 should apply only to 'char' types declared explicitly as signed or unsigned and should not apply to plain 'char' types.

Print this item

  M5-0-20 clarification
Posted by: rt1980 - 25-01-2023, 04:37 PM - Forum: 6.5 Expressions (C++) - Replies (1)

Hi All,

Rule 5-0-20 states that "Non-constant operands to a binary bitwise operator shall have the same underlying type." seems to make sense but my colleagues and I are bit unsure why the non-constant qualifier? 

Consider the following example. It's not clear to us why the first should be allowed if the second is not.

Code:
int foo(int i) {
  const unsigned char mask = ~(0x10);
  return i ^ mask; // compliant: mask is const
}

int foo(int i) {
  unsigned char mask = ~(0x10);
  return i ^ mask; // non-compliant: mask is not const and a different type than i
}


Thanks for your help!
Rafe

Print this item

  Rule 4-5-3 about using relational operators to determine uint8_t
Posted by: zhaohui - 08-12-2022, 08:00 AM - Forum: 6.4 Standard conversions (C++) - Replies (1)

Quote:Exceptionally, the following operators may be used if the associated restriction is observed:
• The binary + operator may be used to add an integral value in the range 0 to 9 to ‘0’;
• The binary – operator may be used to subtract character '0'.
• The relational operators <, <=, >, >= may be used to determine if a character (or wide
character) represents a digit.
According to exceptions and cases of Rule 4-5-3, it seems that Exp1 apples to uint8_t and Exp2, Exp3 apply to character (wide character). And the rule title mainly cares about plain char and wchar_t, so, 
1. What about using uint8_t as operands of relational operators?
2. Which kind of cases does uint8_t violate this rule? Does this rule only check binary operator "+" only for uint8_t?
Code:
void f(void)
{
    char ch = 't';
    if (( ch >= '0') && ( ch <= '9')) // Compliant by exception
    {
        v = ch – '0';                 // Compliant by exception
    }

    unsigned char uc;
    if (( uc >= '0') && ( uc <= '9'))  // compliant or non-compliant?
    {
    }
}

Print this item

  MISRA C:2012 AMD3 published
Posted by: david ward - 05-12-2022, 10:40 PM - Forum: Announcements - No Replies

MISRA C:2012 Amendment 3 (which adds further support for C11/C18 language features) is now available as a free download from the "Resources" section of this Bulletin Board.

Print this item

  MISRA C:2012 AMD3
Posted by: david ward - 05-12-2022, 09:36 PM - Forum: MISRA resources - No Replies

We are pleased to announce the publication of MISRA C:2012 Amendment 3 (MISRA C:2012 AMD3). This document provides additional updates for ISO/IEC 9899:2011/2018 with consideration of new C11/C18 features.

This amendment is intended to be used with MISRA C:2012 (Third Edition, First Revision) as revised and amended by:

  • MISRA C:2012 Technical Corrigendum 2, and
  • MISRA C:2012 Amendment 2
This amendment is also compatible with MISRA C:2012 (Third Edition) as revised and amended by:
  • MISRA C:2012 Technical Corrigendum 1, 
  • MISRA C:2012 Technical Corrigendum 2, 
  • MISRA C:2012 Amendment 1, and
  • MISRA C:2012 Amendment 2.



Attached Files
.pdf   MISRA C 2012 AMD3.pdf (Size: 1.35 MB / Downloads: 51)
Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,170
» Latest member: Huuu
» Forum threads: 996
» Forum posts: 2,750

Full Statistics

Online Users
There are currently 359 online users.
» 0 Member(s) | 357 Guest(s)
Bing, Google

Latest Threads
A18-9-4
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
23-10-2024, 12:04 PM
» Replies: 2
» Views: 347
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 307
model information blocks ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:27 PM
» Replies: 1
» Views: 4,431
MISRA AL SLSF - Rule 043I
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:11 PM
» Replies: 1
» Views: 8,844
MISRA AC EC guidelines
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:21 AM
» Replies: 4
» Views: 15,459
News on future releases
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:05 AM
» Replies: 1
» Views: 5,670
Signal naming convention ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 07:57 AM
» Replies: 1
» Views: 7,222
Rule 7.0.2: operator cons...
Forum: 4.7 Standard conversions
Last Post: karos
14-10-2024, 08:52 PM
» Replies: 2
» Views: 402
MISRA 2023 Test Suite
Forum: General Questions
Last Post: grigdon
14-10-2024, 01:27 PM
» Replies: 0
» Views: 182
MISRA C:2023 ADD4
Forum: MISRA resources
Last Post: david ward
11-10-2024, 07:41 PM
» Replies: 0
» Views: 231