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

Username
  

Password
  





  13.5 for() loops
Posted by: matth1j - 25-02-2005, 05:02 PM - Forum: 6.13 Control Statement Expressions - Replies (2)

Hi

Rule 13.5 (required) states: \"The 3 expressions of a for statement shall be concerned only with loop control\", and
\"First expression: initialising the loop counter.
Second expression: shall include testing the loop counter, and optionally other loop control variables.
Third expression: increment or decrement of the loop counter.\"

The implication would appear to be that for() loops should only be used where there is a loop counter. Is that correct, or could you (for example) use a for() loop without a loop counter, in which case there wouldn't be a first expression?

Is the idea to restrict C's for() usage to that of Pascal's ie.

for var := first [ to | downto ] last do ...

? I'm Ok with this, but I feel that either I'm missing something or the rule isn't explicit enough about what for() can and can't be used for.

Regards
John
NEC Technologies (UK)

Print this item

  Underlying types for bit-fields
Posted by: gs - 21-02-2005, 02:41 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (2)

Can any one tell me how to determine the underlying type of a bit-field? We need to know in order to incorporate testing for MISRA 2 compliance in our product.

Print this item

  MISRA replies to rule questions
Posted by: david ward - 10-02-2005, 01:25 PM - Forum: Announcements - No Replies

You will notice that a few questions have been asked about the rules.

The MISRA C Working Group will review such questions from time to time and, where appropriate, give a considered response. Such a response will be posted under the name \"MISRA Reply\".

Please note that as MISRA is a voluntary activity, we may not be able to respond to every question; nor to guarantee responding to questions within a particular timescale. However, we do intend to post answers to the questions on a semi-regular basis from this time onwards.

Print this item

  Solutions and workarounds to things prohibited in MISRA C
Posted by: MISRA Reply - 10-02-2005, 01:19 PM - Forum: General Questions - No Replies

We have been asked a number of questions about solutions and workarounds for various things that are prohibited in both MISRA C1 and MISRA C2 such as using malloc, calloc, etc. for dynamic memory allocation.

Neither MISRA or any member of the MISRA C Working Group will give any guidance or approval to any deviation or \"workaround\". Any advice that may be given by any individuals associated with MISRA C is entirely personal and is not to be seen as a comment from MISRA or the MISRA C Working Group. In general the advice we would give is:

Where you have decided it is not possible to comply with a rule you should raise a deviation giving your reasons and justifications for doing so. You will have to take documented responsibility for your own deviations.

Read Section 4 (of MISRA-C:2004) on using MISRA C, specifically section 4.3.2 on deviations which outlines how to use deviations.

In general deviations should be as local as possible and as specific as possible and must be subject to sign-off for each deviation (or class of deviation).

Remember YOU will have to take responsibility for your deviations.

Print this item

  Rule 14
Posted by: leire - 04-02-2005, 12:44 PM - Forum: 6.6 Types - Replies (4)

Funtions with parameter of type char as for example \"strcpy\" I can not use signed or unsigned char. Eventhoug the compiler specifies that char is signed, whenever you call strcpy with signed char, there is a compilation error, but if we use the parameter of type char, then we violate rule 14. Does this mean that we must generate our own string manipulation functions?

Print this item

  Underlying Type Presumptions
Posted by: gs - 07-01-2005, 03:13 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (3)

I have made some presumptions regarding the MISRA 2004 concept of Underlying Type. Do correct me if I am wrong in these presumptions.

1. Explicit casts change an expression's underlying type
2. The Standard is not concerned with an expression's underlying type if any of its sub-expressions violate a required underlying type-related rule
3. Implicitly converting an expression (excluding promotions) change its underlying type
4. Effectively Boolean expressions have underlying type of int (see commentary in MISRA 2004, 6.10.2)
5. Enums and enumerations constants have underlying type of int (see C90 Standard, Clause 3, Section 1, Sub-section 3, Part 3)

Does anyone see a problem with any of these?

Print this item

  What about Macros for 14.3?
Posted by: gs - 20-12-2004, 06:59 PM - Forum: 6.14 Control Flow - Replies (2)

Expanding upon the example in the MISRA 2004 Standard for 14.3:


#define WHATABOUTTHIS /* Um */ ;
#define ORTHIS
#define ANDTHISTOO /* Well, I, uh... */

void f()
{
; /* OK */
/* Not OK */ ;
;/* Not OK */
WHATABOUTTHIS
ORTHIS;
ANDTHISTOO;
}

Which of the lines with macros, if any, violate the Rule?

Print this item

  Digests - did anyone try?
Posted by: Erik Leitner - 13-12-2004, 06:28 AM - Forum: General Questions - Replies (5)

Hi everybody,
did anyone of you try the digests function of this MISRA Bulletin Board ?
It seems to me that I got the message \"no posts\" (as usually :-) )although there was a post in a subforum of the misra-rules-forum on Dec 8 and I don't think I have been logged in since then.
(I selected weekly digest)

Erik

Print this item

  What about '\\0'?
Posted by: gs - 08-12-2004, 09:03 PM - Forum: 6.7 Constants - Replies (3)

Does Rule 7.1, \"No octal constants (other than zero) and octal escape sequences shall not be used,\" permit the use of the null character, '\\0'? The normative and rule text exempt 0, per se, but make no mention about '\\0'. Prohibitting '\\0' runs, IMHO, contrary to the Principle of Least Surprise. Perhaps someone would show such kindness as to provide me with some clarity?

I appreciate your time in advance.

Print this item

  Underlying Types
Posted by: gs - 22-11-2004, 06:46 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (3)

I was looking through the MISRA 2 Standard and was wondering what the underlying type of an expression is involving mixed types. For example suppose we are given the following variables:
int i1, i2, *ip;
unsigned char uc;
float f;
What is the underlying type of:
i1 | uc;
i2 ? i1 : uc;
&i1;
ip;
( i1 == i2 );
f;
Since the Standard goes into such detail regarding the concept of \"underlying type\", I feel this is an important issue which, to me, requires clarification.

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,170
» Latest member: Huuu
» Forum threads: 996
» Forum posts: 2,750

Full Statistics

Online Users
There are currently 361 online users.
» 0 Member(s) | 359 Guest(s)
Bing, Google

Latest Threads
A18-9-4
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
23-10-2024, 12:04 PM
» Replies: 2
» Views: 347
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 307
model information blocks ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:27 PM
» Replies: 1
» Views: 4,431
MISRA AL SLSF - Rule 043I
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:11 PM
» Replies: 1
» Views: 8,844
MISRA AC EC guidelines
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:21 AM
» Replies: 4
» Views: 15,459
News on future releases
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:05 AM
» Replies: 1
» Views: 5,670
Signal naming convention ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 07:57 AM
» Replies: 1
» Views: 7,222
Rule 7.0.2: operator cons...
Forum: 4.7 Standard conversions
Last Post: karos
14-10-2024, 08:52 PM
» Replies: 2
» Views: 402
MISRA 2023 Test Suite
Forum: General Questions
Last Post: grigdon
14-10-2024, 01:27 PM
» Replies: 0
» Views: 182
MISRA C:2023 ADD4
Forum: MISRA resources
Last Post: david ward
11-10-2024, 07:41 PM
» Replies: 0
» Views: 231