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

Username
  

Password
  





  MISRA C:2012 Example Suite
Posted by: misra-c - 18-05-2023, 05:01 PM - Forum: MISRA resources - No Replies

For info, the MISRA C:2012 Example suite is now available via the MISRA Git Repository

https://gitlab.com/MISRA/MISRA-C/MISRA-C...mple-Suite

At the moment, this is read-only

Print this item

  MISRA C:2023 released
Posted by: david ward - 12-05-2023, 04:29 PM - Forum: Announcements - No Replies

We are pleased to announce the release of MISRA C:2023 (MISRA C Third edition, Second revision). This is a further update which incorporates Amendments 2 – 4 (AMD2, AMD3, AMD4) and Technical Corrigendum 2 (TC2) and incorporates support for C11 and C18 language features.

At the present time this document is available in PDF form, but we will provide an option for purchase of hardcopies in around 4 – 6 weeks’ time using a “print on demand” service.

Further information including FAQs is available on the MISRA website.

The current version history of MISRA C, with the newest first, is as follows

  • MISRA C:2023 (Third Edition, Second Revision) – published 2023, the current version incorporating support for C11 and C18 language features
  • MISRA C:2012 (Third Edition, First Revision) – also known as MISRA C:2019, published 2019, incorporated additional security guidelines
  • MISRA C:2012 (Third Edition) – published 2013, incorporated support for C99 language features, improved strong typing model, analysis keywords
  • MISRA C:2004 (Second Edition) – published 2004, taking into account user feedback and cross-industry applications
  • MISRA C:1998 (First Edition) – published 1998, original guidance emerging from the automotive industry.

Print this item

  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: 64)
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

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,144
» Latest member: ikoria
» Forum threads: 978
» Forum posts: 2,700

Full Statistics

Online Users
There are currently 102 online users.
» 0 Member(s) | 98 Guest(s)
Applebot, Bing, Facebook, Google

Latest Threads
MISRA C++ 9.6.2
Forum: 4.9 Statements
Last Post: misra cpp
12-07-2024, 11:56 AM
» Replies: 1
» Views: 140
Words in Rule 21.1 and 21...
Forum: 8.21 Standard libraries
Last Post: misra-c
02-07-2024, 03:28 PM
» Replies: 2
» Views: 7,046
Phrase in Rule 21.7 and R...
Forum: 8.21 Standard libraries
Last Post: misra-c
02-07-2024, 03:26 PM
» Replies: 2
» Views: 7,849
"See Also" in Rule 21.1
Forum: 8.21 Standard libraries
Last Post: misra-c
02-07-2024, 03:24 PM
» Replies: 2
» Views: 7,298
A question for Rule21.8
Forum: 8.21 Standard libraries
Last Post: misra-c
02-07-2024, 03:22 PM
» Replies: 2
» Views: 8,458
Shall Rule 21.1 apply to ...
Forum: 8.21 Standard libraries
Last Post: misra-c
02-07-2024, 03:09 PM
» Replies: 1
» Views: 3,802
8.3 and parameter name om...
Forum: 8.8 Declarations and defnitions
Last Post: misra-c
02-07-2024, 09:47 AM
» Replies: 2
» Views: 7,320
Rule 8.4 - main function
Forum: 8.8 Declarations and defnitions
Last Post: misra-c
02-07-2024, 09:44 AM
» Replies: 6
» Views: 11,937
Rule 8.7: clarifications ...
Forum: 8.8 Declarations and defnitions
Last Post: misra-c
02-07-2024, 09:34 AM
» Replies: 1
» Views: 1,198
Floating point test for e...
Forum: 8.10 The essential type model
Last Post: misra-c
02-07-2024, 09:24 AM
» Replies: 2
» Views: 7,779