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

Username
  

Password
  





  Any on-line MISRA reference material with examples?
Posted by: sw_test - 09-09-2019, 03:35 PM - Forum: General Questions - Replies (1)

Hi,

I was wondering if there is any on-line reference material with examples of different MISRA compliance rules and how to fix the issues properly? or is it all only available through the MISRA webstore? https://www.misra.org.uk/Buyonline/tabid...fault.aspx

I'm looking for a way to link to examples for the different MISRA rules but not really seeing something that is similar to seeing issues with CWE, like: http://cwe.mitre.org/data/definitions/825.html

Is there anything similar for the MISRA compliance side of things?

Thanks.

Print this item

  Rule 5.8: identifiers of interest
Posted by: sca2012 - 03-09-2019, 08:24 PM - Forum: 8.5 Identifers - Replies (1)

The main goal of rule 5.8 (as well as 5.9), judging from the examples and amplifications, is to ensure that identifiers referring to objects or functions are not confused with the same identifiers that refer to different objects or functions.

How about identifiers that are reused by do not refer to neither objects nor functions?

For instance, a struct member:

Code:
int i;

struct S {
    int i;    // identifier is reused but cannot actually be confused with the object i at line 1
};
Is this scenario still a violation to the rule?

Print this item

  Rule 0-1-7 Exception clarification
Posted by: udi - 01-09-2019, 01:36 PM - Forum: 6.0 Language independent issues (C++) - Replies (1)

Hi,

I have 3 questions:
1. Why in the exception for the rule, a C-style cast was used (like in case #1 below), instead of functional notation cast (like in case #2 below)?
2. Does using a functional notation cast violates this rule?
3. Is it legit to do the cast through a typedef as shown in case 3 (or 4 in case that functional notation cast is allowed for that purpose)?

Thanks,
Udi.
==== Below are the referenced code examples ===
namespace SE
{
typedef void UnusedRetVal;
}

1. (void)std::strtol(pszValue, &pszEndPtr, 10); // copmliant
2. void(std::strtol(pszValue, &pszEndPtr, 10)); // not compliant ?
3. (SE::UnusedRetVal)std::strtol(pszValue, &pszEndPtr, 10); // not compliant ?
4. SE::UnusedRetVal(std::strtol(pszValue, &pszEndPtr, 10)); // not compliant ?

Print this item

  Use a subset of MISRA Rules
Posted by: gauthamkrishnan.r - 23-08-2019, 12:01 AM - Forum: General Questions - Replies (3)

Can I use only a subset of the MISRA C:2012 Guidelines for my project?

Print this item

  Clarification for Rule 5-2-4
Posted by: abgs - 26-07-2019, 02:06 PM - Forum: 6.5 Expressions (C++) - Replies (1)

1. Does the phrase "functional notation cast" in the rule correspond to what the C++ standard calls an "Explicit type conversion (functional notation)", or is there a distinction?

2. Does the phrase "explicit constructor call" in the rule mean "explicit-constructor call" (a call to a constructor declared with the 'explicit' specifier) or "explicit constructor-call" (an explicit call to a constructor, as opposed to an implicit conversion that uses a user-defined converting constructor)?

3. The rationale refers to dangers associated with casts that "do not invoke a converting constructor", however a "converting constructor" is a constructor that was *not* declared with the 'explicit' specifier. Was this intended to refer to casts that *do* invoke a converting constructor [as opposed to an explicit constructor]?

4. In the first compliant example with the expression 'A(10)' the declared constructor 'A(int32_t)' is declared with the explicit specifier. Would the 'A(10)' example be non-compliant if this constructor declaration lacked the 'explicit' specifier?

5. In later versions of the C++ standard, "Explicit type conversion (functional notation)" includes a type name followed by a braced list, e.g. 'X{5}', which may be used for aggregate initialization for 'struct X { int32_t a; };'. Is it within the original spirit of the rule to include this sytnax?

Print this item

  What is "a genuine issue that is not a violation" in "3.4 Investigating messages"?
Posted by: yohura - 25-07-2019, 01:20 AM - Forum: MISRA Compliance discussions - Replies (1)

Hi all,

I'm not sure about "Diagnosis of a genuine issue that is not a violation" in "3.4 Investigating messages".
Are there any example of genuine issue that is not a violation ?

Best regards,

Print this item

  Welcome!
Posted by: david ward - 24-07-2019, 01:40 PM - Forum: MISRA Compliance discussions - No Replies

This new forum has been set up for asking questions about and discussing MISRA Compliance:2016 "Achieving compliance with MISRA Coding Guidelines"

The MISRA C Working Group will consider questions posted here and if appropriate give an official response (which will be posted by the "misra-c" user). Any other comments and responses from any posters shall not be considered an official MISRA position.

We expect to respond to questions on an approximately monthly basis so if you don't hear from us, please bear with us as we have day jobs to do too!

Please note some previous forum questions have been moved into here as a more appropriate location.

Print this item

  Underlying type's implicit conversion of the shift operators
Posted by: chill - 19-07-2019, 11:49 AM - Forum: 6.5 Expressions (C++) - Replies (1)

Is there a implicit conversion in shift expressions?

Quote:The underlying type of the result is the underlying type of the shift-expression.

[code]
int8_t i8;
uint8_t u8;
uint32_t u32;
int32_t i32;

u32 + i8; // i8 -> u32
u32 += i8; // i8 -> u32

u32

Print this item

  How to deal mandatory rules in the MISRA compliance 2016?
Posted by: yohura - 11-07-2019, 07:10 AM - Forum: MISRA Compliance discussions - Replies (2)

I'm reviewing code based on the MISRA compliance 2016, and want to know interpretation of mandatory rules in the adopted code.
In MISRA compliance 2016, violate mandatory rules must not be permitted, but "non-compliant adopted code" is reasonable to deviate the rules.
Should I fix the code pointed out by mandatory rules, or need not ?

Print this item

  Question about Dir 4.3 when a static function contains only variable declaration, asm and return statement
Posted by: chenzhuowansui - 29-06-2019, 09:39 AM - Forum: 7.4 Code design - Replies (8)

Hi,
Given the following case:

Code:
static inline uint32_t test(void)
{
    uint32_t tmp;

    __asm__ __volatile__(
        "mrc p15, 0, %0, c1, c0, 2\n\t"
        : "=r" (tmp)
        );

    return tmp;
}

i wonder if we could take the above case as compliant, as we cannot have variable declaration and return value in assembly. Thanks

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,206
» Latest member: nileseo4605
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

Online Users
There are currently 174 online users.
» 0 Member(s) | 170 Guest(s)
Applebot, 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: 158
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 286
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 272
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 180
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: 198
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: 158
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 242
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 201
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 259
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: 673