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

Username
  

Password
  





  Proposal: Rule 0-1-4 exception
Posted by: dg1980 - 27-10-2016, 11:16 AM - Forum: 6.0 Language independent issues (C++) - Replies (2)

Exception: Variables which are written by the program but read by an external entity (e.g. ASAM MCD tools like Vector CANape) are not considered a violation of this rule.

Print this item

  Proposal: Rule 0-1-3 exception
Posted by: dg1980 - 27-10-2016, 11:09 AM - Forum: 6.0 Language independent issues (C++) - Replies (3)

Dear MISRA team,

we have certain variables which are required by our boot loader (a separate binary) but are not used in the main program itself.
In my book, this is not a violation of 0-1-3, because clearly those variables have a usage, albeit one that static analysis cannot prove.
Therefore i would like to propose the following addendum to rule 0-1-3:

Exception: a variable which is required by an external binary program only (e.g. an embedded systems boot loader) is not considered a violation of this rule.

Print this item

  Rule 9-3-2
Posted by: dg1980 - 21-10-2016, 12:07 PM - Forum: 6.9 Classes (C++) - Replies (1)

Dear MISRA team,

i think in the example below, the non-const get_p is a violation of this rule, while the static analysis tool says otherwise.
The compliant example in the document refers to shared data, which is not the case here.
I think it was misinterpreted as "returning a member of type T* is always compliant".
If so, maybe in the next version of the standard this rule needs a better formulation in terms of exceptions.

Code:
FlexeLint for C/C++ (Unix) Vers. 9.00L, Copyright Gimpel Software 1985-2014
--- Module: diy.cpp (C++)
     1  //lint -indirect(au-misra-cpp-alt.lnt)
     2  namespace
     3  {
     4    typedef unsigned char ui8;
     5    class cFoo
     6    {
     7    public:
     8      cFoo(void) : arr(), p(&arr[0]){}
     9      ui8* get_p(void){return p;}
    10      const ui8* get_p(void) const{return p;}
    11    private:
    12      ui8 arr[4];
    13      ui8* p;
    14    };
    15  }
    16  
    17  

--- Wrap-up for Module: diy.cpp

Print this item

  Rule 10.3, conversion of constant expression
Posted by: Motozo Mario Ikeda - 19-10-2016, 11:30 PM - Forum: 8.10 The essential type model - Replies (6)

It is hard to understand the reason to add Amplification 2 "The conversion of the constant expression in a switch statement's case label to the promoted type of the controlling expression".

What kind of risks should be eliminated with this?

Thank you,
Mario Ikeda

Print this item

  Rule 2.1 deviation permit?
Posted by: dg1980 - 19-10-2016, 02:15 PM - Forum: 7.2 Compilation and build - Replies (2)

Typically, on embedded systems with a simple RTOS, main is used as background task, so it never returns:

Code:
int main(void)
{
  Setup_Rtos();
  for (;;)
  {
    Background_Task();
  }
  return 0;// Violates MISRA C 2012 2.1: unreachable code
}

Would this be a candidate for your deviation permits document?

Print this item

  MISRA C:2012 and ISO/IEC 9899:2011 (C11)
Posted by: andream - 18-10-2016, 12:08 PM - Forum: 7.1 The implementation - Replies (4)

MISRA C:2012 has made reference to ISO/IEC 9899:1999 (C99). As of 2011, there is the latest ISO/IEC 9899:2011 (C11). I wonder if any Supplement, Amendment or slight change has been prepared in this respect. Or MISRA C:2012 is invariant w.r.t said latest ISO standard?

Print this item

  Note 9003: could define variable at block scope
Posted by: PeterW - 12-10-2016, 08:39 AM - Forum: 8.9 Initialization - Replies (2)

Hi,
In my code I have a static const array which is declared outside the block scope of the function where it’s used. Also it is only used by one function, so the Note 9003 is correct.
But the array is large and will ruin the overview of the function. So I want to suppress the warning using /*lint -e9003*/ before the array and /*lint +e9003*/ behind it.
But this has no effect. As I suppress the warning global it works, but this shall not be the way to do.
Any idea how to suppress the warning local for just one variable?

Print this item

  Mixed C/C++ build environment
Posted by: dg1980 - 11-10-2016, 11:40 AM - Forum: C++ General - No Replies

Could you write an explicit chapter on how to deal with this situation in the next version of the standard?
For example, i don't think this is what MISRA intended: http://support.gimpel.com/forums/225702-...th-mixed-c
Also, consider adding exceptions to some rules in the context of headers being included in both C and C++ modules:

Code:
#ifndef FOO_H
#define FOO_H

#define MAGIC_CONSTANT 123456/*Violates MISRA C++ Rule 16-2-2, but is fine in C and changing would require storage in C (effiency)*/
typedef int int32_t;

#ifdef __cplusplus
extern "C"
{
#endif

int32_t foo_api(void);

#ifdef __cplusplus
}
#endif

#endif

Thank you very much.

Print this item

  MISRA C:2012 has no explicit library-specific restriction on <stdarg.h>?
Posted by: bycho - 11-10-2016, 09:26 AM - Forum: 7.1 The implementation - Replies (1)

A presentation slide from Andrew Banks, Chairman of MISRA C Working Group, says
that MISRA C:2012 has no explicit library-specific restriction on 7 standard headers and among these is included.
(page 13, http://www.open-std.org/jtc1/sc22/wg14/w.../n2035.pdf)
so I thought I would be able to check whether a program is a conforming freestanding program or not by applying MISRA C:2012 guidelines.

However, in MISRA C:2012 Rule 17.1 says the features of shall not be used.

I think some rules of MISRA C:2012 are too restrictive to use in various kinds of industries.
Moreover, it makes me unhappy that complying with MISRA C:2012 doesn't imply conforming freestanding implementation.

is the slide wrong? or is there any mistake in my mind?
I'm beginner in MISRA guidelines, so I might have lots of errors.
I will appreciate your advices and help.

Print this item

  Rule 8.3 type qualifier
Posted by: Motozo Mario Ikeda - 07-10-2016, 01:38 AM - Forum: 8.8 Declarations and defnitions - Replies (3)

"Type qualifier" and "Storage class specifier" are mentioned in Rule 8.3, but "Type specifier" is not.

Should we think "Type qualifier" includes "Type specifier"?

Thank you,
Mario Ikeda

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,207
» Latest member: MLBstubs
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

Online Users
There are currently 153 online users.
» 0 Member(s) | 150 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: 167
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 296
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 277
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 186
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: 206
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: 164
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 258
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 211
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 266
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: 691