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

Username
  

Password
  





  11.4 A cast should not be performed ...
Posted by: Frank Haug - 06-11-2007, 10:13 AM - Forum: 6.11 Pointer Type Conversions - Replies (1)

... between a pointer to object type and a different pointer to object type (advisory).

Additional comment: \" Conversions of this type may be invalid if the new pointer type requires a stricter alignment.\"

---

I think there can be further risks. I suppose - e.g. - casting a signed pointer onto an unsigned pointer (of the same bitwidth and alignment) itself is not risky. Dangerous can be to WORK with the casted pointer regarding its content, it is pointing onto. In this case the cast itself would not be dangerous, but the possibilities afterwards are.

example:

unsigned int foo (signed int* ps)
{
unsigned int* pu;

pu = (unsigned int*) ps; // assumed to be no problem itself
*pu = ... ; // assumed to be no problem itself
// but can be a problem later, when the content of the incoming pointer is used afterwards
}

Can anybody confirm ? I think it can be of interest to know the problems in more precision. Does anybody know other implications (not applying such casts) ?

Regards,
Frank

Print this item

  14.1 There shall be no unreachable code
Posted by: Frank Haug - 24-10-2007, 07:27 AM - Forum: 6.14 Control Flow - Replies (10)

The wording of 14.1 does not clarify the issue clear enough. I've discussed with several experienced persons and the common of these discussions is, that the questions only can be resolved, if someone ADDS personal interpretations. That cannot be the intension of a rule (text).

Firstly, \"defensive programming\" is not a misra rule. In my opinion this is a severe lack in/on the misra rule set. Although not explicitly defined its used in the rule text of 14.1 and its used in a confusing way: \"Code that can be reached but may never be executed is excluded from the rule (e.g. defensive programming)\".

In my tries to understand this, I refactored this sentence on following part (and nobody out of my discussions with Developers and QA Managers could give me an answer on that):

What is \"code, that can be reached but (may) never be executed\" ?

The provided example does not answer this question, because it shows code that \"exists but never will be reached\".

Maybe it helps to concretesize my intention when I re-word above sentence as follows: \"Is it possible, that code can be reached but not executed ?\"

Thanks in advance

Frank

Print this item

  Macros & 14.3 II
Posted by: gs - 22-10-2007, 02:51 PM - Forum: 6.14 Control Flow - Replies (1)

Since, according to http://www.misra-c2.com/forum/viewtopic.php?t=264, the following code is not permitted:

Code:
#if debugging
#define ASSERT(x)    asserttest(x)
#else
#define ASSERT(x)
#endif

void f(int *p)
    {
    ASSERT(p != 0);
    }

How would one make code well formed with respect to assertion macros?

Print this item

  Rule 19.9
Posted by: frankdelamarre - 08-10-2007, 12:38 PM - Forum: 6.19 Preprocessing Directives - Replies (1)

Can you please supply an example of a violation of rule 19.9? This would help to understand what the rule is really trying to enforce.

Print this item

  MISRA C:2004 rule 19.4 / extension
Posted by: Laessle - 26-09-2007, 05:59 AM - Forum: 6.19 Preprocessing Directives - Replies (1)

In our code we want to use generic macros of kind

#define macro(a) int array[2] = {a, a};

unfortunately a do-while-zero loop does not helps, cause defined objects are only known within the loop.

So we would like to ask for a further exception of the described kind.

In the attachment you will find an example to demostrate the intention of such macros.
The program reads values of an Analog Digital Converter (via SPI) and writes modified values to a Pulswidth Generator (also via SPI).
All transfers are coded in an array (Transfer_List). The contents of the array depends on the hardware (baudrate, data-format) and the tranfer-typ (read, write
number of values). The C-file has no hardware dependant function. All hardware specific settings are encapsulated in the macro Create_Transfer_List.
Modifying the hardware only needs to modify the macro. Further I/Os can be implemented very easily.

We would appreciate your positve response.

Mit freundlichen Grüßen/Best regards,

Hans-Peter Lässle
Control Systems
ETC-D

Continental Teves AG & Co. oHG
Guerickestr. 7, D-60488 Frankfurt am Main
P.O. Box 900120, D-60441 Frankfurt am Main

Telefon/Phone: 0049 69 7603-5418
Telefax: 0049 69 7603-3990
E-Mail: [email protected]
http://www.contautomotive.com
_____________________________________________________

Continental Teves AG & Co. oHG, Guerickestr. 7, D-60488 Frankfurt am Main
Sitz der Gesellschaft/Registered Office: Frankfurt am Main, Registergericht/Registered Court: Amtsgericht Frankfurt am Main HR A 27047, USt.-ID-Nr./VAT-ID-No. DE 112160365
Gesellschafter/Shareholders: Continental Aktiengesellschaft (geschäftsführend/managing)
Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: Dr. Hubertus von Grünberg
Vorstand/Executive Board: Manfred Wennemer (Vorsitzender/Chairman), Dr. Alan Hippe, Gerhard Lerch, Dr. Karl-Thomas Neumann, Dr. Hans-Joachim Nikolin, Heinz-Gerhard Wente, William L. Kozyra (stv./Deputy)
Sitz der Gesellschaft/Registered Office: Hannover, Registergericht/Registered Court: Amtsgericht Hannover HR B 3527
Continental Teves UK Ltd., Company Number 00700225, Ebbw Vale, Wales, Großbritannien/Great Britain
_____________________________________________________
Proprietary and confidential. Distribution only by express authority of Continental AG or its subsidiaries.

Print this item

  Infinite loop
Posted by: JonM - 12-09-2007, 01:29 PM - Forum: 6.13 Control Statement Expressions - Replies (3)

What is the preferred implementation of an infinite loop?

Code:
for ( ; ; ) ...

or

Code:
while (1 == 1) ...

or

something else?

Thanks in advance.

Jonathan

Print this item

  why example suite not test suite
Posted by: MMouse - 27-07-2007, 08:14 AM - Forum: MISRA-C:2004 Exemplar Suite - No Replies

Why is it an example suite and not a test suite?

what can we use the example suite for?

Print this item

  New discussion topic - Exemplar Suite
Posted by: david ward - 26-07-2007, 02:52 PM - Forum: MISRA-C:2004 Exemplar Suite - Replies (3)

This topic is for questions and discussions related to the Exemplar Suite. For questions or discussions relating to the Rules which arise from using the Exemplar Suite, please post these in the appropriate Rule topic.

Print this item

  MISRA C TC1 and Exemplar Suite now available
Posted by: david ward - 20-07-2007, 01:44 PM - Forum: Announcements - No Replies

MISRA is pleased to announce the availability of the following resources for MISRA C:

  • Exemplar Suite
  • Technical Clarification 1 for MISRA-C:2004.
You can download the Exemplar Suite and TC from the "Resources" section of this Forum website which is visible when logged in as a registered user. Follow the link at the top of the page to register if you are not already a registered user.

July 2008: Note that a new edition of MISRA-C:2004 that incorporates the TC text is now available.

Print this item

  MISRA C:2004 Exemplar Suite
Posted by: david ward - 20-07-2007, 01:41 PM - Forum: MISRA C resources - No Replies

This suite of files is intended to illustrate issues addressed by the MISRA C rules as expressed in:

  1. MISRA-C:2004 Guidelines for the use of the C language in critical systems, ISBN 0 9524156 2 3 paperback and ISBN 0 9524156 4 X PDF.
  2. MISRA-C:2004 Technical Corrigendum 1
This Exemplar Suite is not exhaustive, but provides examples of key issues.

Please note that the Exemplar Suite is not a compliance or conformance test suite, since considerably more examples would also be needed in such a suite. Also MISRA does not offer compliance or conformance testing for tools or products.

Use of this Exemplar Suite is subject to the conditions in the enclose READ_ME file. In particular please note that a free license of these code examples is offered only for individual use. Redistribution of the code examples in any form is not permitted. If you wish to use the Exemplar Suite in this way, including distribution with a tool, please contact MISRA for licensing terms.

This suite will be updated from time to time. You can check you have the latest version by visiting this area of the MISRA Forum. There is an MD5 checksum provided in the file description that can be used to check that a copy of the archive is a genuine copy.  The date and version number of the latest release will always be listed at the end of this post.

Version history

Version number: 1.0
Date: 17 July 2007
Reason: Initial release

Latest release

Version number: 1.0
Date: 17 July 2007



Attached Files
.zip   MISRA-C_exemplar_suite_2007_07_17.zip (Size: 126.71 KB / Downloads: 18)
Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,110
» Latest member: jeehoon.son
» Forum threads: 964
» Forum posts: 2,648

Full Statistics

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

Latest Threads
Rule 6-2-3 and C++17 [[fa...
Forum: 6.6 Statements (C++)
Last Post: kafka
27-03-2024, 02:44 PM
» Replies: 0
» Views: 16
10.2.3 Amplification
Forum: 4.10 Declarations
Last Post: hahn
26-03-2024, 03:08 PM
» Replies: 0
» Views: 23
MISRA AC GMG:2023 release...
Forum: MISRA AC GMG discussions
Last Post: misra-ac
25-03-2024, 06:01 PM
» Replies: 2
» Views: 259
14.3 and enum constants i...
Forum: 8.14 Control statement expressions
Last Post: misra-c
24-03-2024, 01:08 PM
» Replies: 1
» Views: 207
Rule 7.0.5 Example potent...
Forum: 4.7 Standard conversions
Last Post: danix800
21-03-2024, 01:57 PM
» Replies: 0
» Views: 44
0-1-8. Exception: empty i...
Forum: 6.0 Language independent issues (C++)
Last Post: vmuthusu
18-03-2024, 04:01 AM
» Replies: 3
» Views: 8,152
Rule 0.2.4 non-compliant ...
Forum: 4.0 Language independent issues
Last Post: danix800
15-03-2024, 02:20 PM
» Replies: 0
» Views: 65
Rule 19.1 Example
Forum: 8.19 Overlapping storage
Last Post: misra-c
13-03-2024, 10:31 AM
» Replies: 3
» Views: 7,913
Rule 13.5
Forum: 8.13 Side effects
Last Post: misra-c
13-03-2024, 10:09 AM
» Replies: 1
» Views: 206
cvalue and constant integ...
Forum: AUTOSAR C++:2014 rules
Last Post: gerbor
12-03-2024, 12:17 PM
» Replies: 0
» Views: 66