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

Username
  

Password
  





  12.6 boolean expression assigned to int example
Posted by: pkruk - 14-05-2008, 09:15 AM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

Code:
uint16_t mc2_1206_x;
   uint16_t mc2_1206_y;
   uint16_t mc2_1206_z;
   mc2_1206_x = ( mc2_1206_y == mc2_1206_z ); /* Not compliant - mc2_1206_x is not effectively boolean */

This code has been marked as violation of rule 12.6 but I fail to see why. There are no (&&, || and !) operators so the first part of the rule does not apply. The boolean expression is used as operand of "=" so the second part of the rule is complied to as well.
Please correct me if I'm wrong.

Print this item

  Rule 12.2 and "nested assignment statements"
Posted by: pkruk - 14-05-2008, 07:42 AM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

Example from mc2_1203.c:

Code:
mc2_1203_x = sizeof ( mc2_1203_a = 1234U );

Is this code also a violation of rule 12.2 "nested assignment statements"?

Print this item

  Rule 12.1 - are extra parentheses not compliant?
Posted by: pkruk - 13-05-2008, 02:36 PM - Forum: 6.12 Expressions - Replies (1)

Quote:However, do not add too many parentheses so as to clutter the code and make it unreadable.
Does it means that the "not required" parentheses below are a violation of this rule? If not, is there a case where too many parentheses is a violation to this rule?
Code:
x = a + b; /* acceptable */
x = (a + b); /* () not required */

Print this item

  Rule 8.3 - incorrect example or missing comment
Posted by: pkruk - 12-05-2008, 01:04 PM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

Function declaration in mc2_0803.h:

Code:
extern void mc2_0803_2 ( my_s32bit_int param0803 );
Function definition in mc2_0803_2.c:
Code:
void mc2_0803_2 ( my_other_s32bit_int param0803 )

The types are different (different typedef names) - either there should be "Not Compliant" comment or the type should be changed.

Print this item

  Rule 19.9 - incorrect comment in mc2_1909.c?
Posted by: pkruk - 09-05-2008, 02:21 PM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

mc2_1909.c contains following code:

Code:
#define SUM(A,B,C) ((A) + (B) + (C)) /* Violates Rule 17.4 */

Rule 17.4 is "Array indexing shall be the only allowed form of pointer arithmetic." - the code does not seem to be violation of this rule.

Print this item

  Left Shifts and Castings
Posted by: gs - 05-05-2008, 07:33 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (2)

Is the following acceptable under 10.5?
[code]
unsigned char u = 1u;
(unsigned char) u

Print this item

  MISRA SA Errata
Posted by: david ward - 01-05-2008, 03:36 PM - Forum: MISRA SA resources - No Replies

Regrettably there are a few errata in MISRA SA, both in the print and PDF versions. The attached file contains the corrected pages and the errata are as follows:

  • Page 77 - Figure A.4 was missing the solid line around the air pipe and air spring (affects print version only)
  • Page 83 - Figure C.1, same issue (affects print version only)
  • Page 93 - Figure E.1, the third formula was incorrect and should read P(F|A) (affects both versions).
New PDF purchases have been corrected so the third issue is only present in PDFs purchased before 11 April 2008.



Attached Files
.pdf   MISRA SA Errata Apr 08.pdf (Size: 240.25 KB / Downloads: 14)
Print this item

  READ ME FIRST
Posted by: david ward - 01-05-2008, 03:31 PM - Forum: MISRA SA resources - No Replies

This area of the Forum provides downloadable resources associated with MISRA Publications.

Please note that by downloading a resource you accept the license conditions associated with it.

Further details are given with each file.

Print this item

  MISRA C++ launch
Posted by: david ward - 01-05-2008, 03:27 PM - Forum: C++ Announcements - No Replies

MISRA is pleased to announce that MISRA C++ will be published on 5 June 2008 and launched at the Safety-Critical Systems Club Tools Event in London on that date. Please see http://www.scsc.org.uk/diary.html?opt=detail&id=70 for details of the event and how to register.

A more in-depth workshop/tutorial session on MISRA C++ is planned for the MISRA Conference in late 2008 and further details will be available later in the year.

Copies of MISRA C++, in both hardcopy and PDF formats, will be available to purchase from the MISRA webstore after the launch date. Prices will be announced nearer the time. We regret that we cannot accept pre-orders for the document at this time.

Print this item

  Rule 4.1 Question
Posted by: fbdog - 01-05-2008, 02:49 PM - Forum: MISRA-C:2004 Exemplar Suite - Replies (1)

Hello,

I was just wondering if anybody has come across a possible discrepancy with the Exemplar Test suite 4.1. In the MISRA 2004 standard, Rule 4.1 states that "Only those escape sequences that are defined in the ISO C Standard shall be used". Section 5.2.2 of the ISO C standard lists valid escape sequences, but section 6.4.4.4 in the ISO C Standard also further defines escape clauses that are used.

The Rule 4.1 test case lists hexadecimal escape clauses as being non-compliant, but section 6.4.4.4 in the ISO C Standard indicates that hexadecimal clauses are valid.

I am just wondering if anybody has considered this is as a mistake in the test suite?

Thanks,
Jerry

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,213
» Latest member: RichardEdward
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

Online Users
There are currently 93 online users.
» 0 Member(s) | 89 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: 187
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 322
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 304
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 198
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: 218
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: 184
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 290
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 222
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 281
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: 726