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

Username
  

Password
  





  Rule 10.5 cast of enum to boolean
Posted by: misra-c - 09-10-2014, 08:36 AM - Forum: 8.10 The essential type model - Replies (1)

Code:
#include

typedef enum{ NOT_OK, OK, MAYBE } assessment;

void foo (assessment a)
{
  bool result;
  result = (bool) NOT_OK;    /* [1] compliant with MISRA C:2012 Rule 10.5? */
  /*. . . */
  result = (bool) a;         /* [2] not compliant with MISRA C:2012 Rule 10.5? */
  /*. . . */
}
The exception to Rule 10.5 permits a cast of an integer constant expression with the value 0 or 1 to a type which is defined as essentially Boolean. However the rule does not permit the cast of objects with essentially enum type to an essentially Boolean type.

Am I correct to say that [1] is compliant with rule 10.5, but [2] is not compliant?

Print this item

  Rule 2.5 Does #undef count as a "use"
Posted by: misra-c - 09-10-2014, 08:31 AM - Forum: 8.2 Unused code - Replies (3)

Rule 2.5 Is #undef considered a “use” of a macro”?
For example

Code:
#define M1 This
   #define M2 That
   #undef M1
   use( M2 );
Is 'M1' unused and therefore violate rule 2.5, or does the #undef count as a use of M1?

Print this item

  Is a function parameter “used” if cast to void?
Posted by: misra-c - 09-10-2014, 08:29 AM - Forum: 8.2 Unused code - Replies (1)

Does the following violate rule 2.7 (There should be no unused parameters in functions)?

Code:
void fn ( int32_t param )
{
   ( void )param;
}

Print this item

  A question for Rule8.3
Posted by: nyoshi - 02-10-2014, 05:31 PM - Forum: 8.8 Declarations and defnitions - Replies (1)

I have a question for an exception of Rule8.3.

I think that the structure "tab" of the following sample does not have compatibility.
Is this right?

Code:
[test1.c]
struct tab {
   signed char a;
   signed short  b;
};

struct  tab a;

[test2.c]
Code:
struct tab {
   signed char a;
   signed short int  b;
};

extern struct tab a; /* non-compliant - incompatible version */

Best Regards,
nyoshi

Print this item

  9.References on MISRA-C:2012
Posted by: ogawa.kiyoshi - 23-09-2014, 08:34 AM - Forum: General Questions - Replies (1)

I am checking the 9.References on MISRA-C:2012.

[1] MISRA Guidelines for the Use of the C Language In Vehicle Based Software ISBN 0-9524159-9-0, Motor Industry Research
Association, Nuneaton, April 1998.
This is ISBN 10.

It was also in the reference on MISRA-C 2004.

but

On a paper book of Guidelines for the Use of the C Language in Vehicle Based Software
ISBN 0-9524156-9-0
This is ISBN 10.

Please check them.

In Japanese Guide to guideline for MISRA-C:2004,
the reference of the document was ISBN 0-9524156-9-0.
We might report it already.

BTW.,
In misra web site http://www.misra.org.uk/Publications/tab...fault.aspx
Guidelines for the Use of the C Language in Vehicle Based Software, ISBN 978-0-9524156-6-5, April 1998.
This is ISBN 13.

Best Regards.
Dr. Kiyoshi Ogawa
@kaizen_nagoya

Print this item

  Rule 8.8
Posted by: Akhil - 04-09-2014, 12:14 PM - Forum: 8.8 Declarations and defnitions - Replies (1)

1. extern int s=10;
2. static int s;
3.
4. void foo()
5. {
6. /* Do Something*/
7. }


Is line 1 non compliant for Rule 8.8 in the above example. I'm confused since line 1 gives a definition and not just declaration.
Here I'm not able to make out whether the var 's' have external or internal linkage.

My compiler binds 's' var with extern linkage if a definition is given with extern.(is value is also assigned like the above case).

Print this item

  Meaning of MISRA AC SLSF 045B (par. 3.6.11)
Posted by: neffnan - 29-08-2014, 03:08 PM - Forum: MISRA AC SLSF discussions - Replies (1)

I can't make sense of the wording of 045B. I think there may be a copy-&-paste problem--the English seems garbled--but I'm not sure enough of my understanding of Stateflow yet to figure out what the 'correct' and 'incorrect' examples are meant to convey, so I'm not comfortable assuming how the rule should read. Could someone perhaps explain this rule for me or tell me how the rule should read? Thanks.

Print this item

  7-3-1 declarations and definitions
Posted by: gs - 25-08-2014, 04:33 PM - Forum: 6.7 Declarations (C++) - Replies (1)

Does rule 7-3-1 require a function declared at global scope be declared as "extern 'C'" for both the function's declaration and its definition or does one "extern 'C'" for that function suffice? For example, is this okay:

Code:
extern "C" void f();
void f() {}

Print this item

  Abandoned?
Posted by: gs - 25-08-2014, 04:31 PM - Forum: C++ General - Replies (3)

Given the general lack of response with respect to MISRA C++ guidelines, is it fair to say MISRA C++ has been effectively "abandoned" by the committee?

Print this item

  Rule 8–4–4 (Required) function identifier with & or ()
Posted by: Achim Olaf Zacher - 13-08-2014, 07:38 PM - Forum: 6.8 Declarators (C++) - Replies (5)

Is it intended to ban the use of
[code]std::cout

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,171
» Latest member: stephanmuench
» Forum threads: 998
» Forum posts: 2,752

Full Statistics

Online Users
There are currently 288 online users.
» 0 Member(s) | 287 Guest(s)
Bing

Latest Threads
Rule 6.2.1: non-inline co...
Forum: 4.6 Basic concepts
Last Post: cgpzs
22-11-2024, 10:11 AM
» Replies: 0
» Views: 24
Rule 0.1.2
Forum: 4.0 Language independent issues
Last Post: stephanmuench
21-11-2024, 01:12 PM
» Replies: 0
» Views: 35
A18-9-4
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
23-10-2024, 12:04 PM
» Replies: 2
» Views: 369
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 325
model information blocks ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:27 PM
» Replies: 1
» Views: 4,444
MISRA AL SLSF - Rule 043I
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:11 PM
» Replies: 1
» Views: 8,861
MISRA AC EC guidelines
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:21 AM
» Replies: 4
» Views: 15,501
News on future releases
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:05 AM
» Replies: 1
» Views: 5,691
Signal naming convention ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 07:57 AM
» Replies: 1
» Views: 7,246
Rule 7.0.2: operator cons...
Forum: 4.7 Standard conversions
Last Post: karos
14-10-2024, 08:52 PM
» Replies: 2
» Views: 431