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

Username
  

Password
  





  Casting a Float to a Signed Integer
Posted by: embedded.kyle - 05-03-2007, 10:04 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (1)

I'm working with some legacy code and part of my job is to modify it to comply with the MISRA standard. A large portion of the code relies on macros such as this one:

[code]#define CURRENT_LARGE_SHIFT (18L)
#define CURRENT_LARGE_SCALE(v) (int32_t)(v * (1L

Print this item

  Other question about pointer to void
Posted by: fwamolina - 07-02-2007, 08:48 PM - Forum: 6.11 Pointer Type Conversions - Replies (1)

In misraC-2004 when starts section 6.11 - Pointer type Conversion says the following:

\"Conversions involving pointer types require an explicit cast except when:
The conversion is between a pointer to object an a pointer to void....\"

my question is if this example is compliance with that.

Code:
void func (void)
{
  void*          pt_V;
  uint8_t*       pt_A;
  uint32_t*      pt_B;

  .
  .
  .

  pt_V = pt_A;

  /* use pointer */

  pt_V = pt_B;

  /* use pointer */

  .
  .
  .
}

thank you.

Print this item

  Boolean Types
Posted by: djtachyon - 05-02-2007, 07:08 PM - Forum: 6.6 Types - Replies (1)

Just wondering what is the best way to define a boolean type for MISRA and most importantly what to define TRUE and FALSE as.

Some thoughts:

typedef unsigned char boolean_t
#define TRUE (0==0)
#define FALSE (!0)

Thanks.

Print this item

  MISRA C 2004 Compliance Matrix
Posted by: Anonymous - 11-01-2007, 09:32 AM - Forum: General Questions - Replies (1)

Is there a template of the required Compliance Matrix available?

I would like to see such a matrix include the rule synopsis as well as it's ID, so that it is easy to comprehend.

Having purchased the MISRA-C 2004 PDF, I find that it is protected such that I cannot copy the contents of Appendix A as a good starting point.

Regards
Dave Banham

Print this item

  Void Pointer Usage
Posted by: MikeS - 11-01-2007, 09:04 AM - Forum: 6.11 Pointer Type Conversions - Replies (1)

Hi,

I have a question regarding the use of Void pointers.

Rule 11.2 is the rule that applies (Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to object or a pointer to void).

My first question is:
How do you define \"a pointer to object\"?
By this, do you mean structure, derived types?
I couldn't see any definition for this in the MISRA text.

My second question is:
This rule allows the conversion of a pointer from one type to void. (i.e. to a NULL_PTR to allow for error checking)
I think that this rule also prohibits the use of a defined void ptr, converting this to point to an array or other obect, is this correct?

i.e. the following is illegal:

void *pv_my_void_ptr = NULL_PTR;
u16 *pu16_my_int_ptr = (u16 *)pv_my_void_ptr;

As this would make the checking of alignment (i.e. Rule 11.4) impossible as well as hiding the original type pointed to?

Many Thanks for your consideration.

Mike.

Print this item

  Complementary documentation on MISRA Rules
Posted by: Nicolette MAZURIER - 11-12-2006, 11:07 AM - Forum: General Questions - No Replies

I am working as a Software Quality Engineer at Siemens VDO in France and we are currently trying to document the consequence(s) of not respecting each of the MISRA rules, in order to make our developers aware of the risk(s). Sometimes this task is quite easy and sometimes less. So I am looking for some documentation that could help us reaching our objective. Today we are still using MISRA 1998, so I am more interested in documents dealing with the correponding rules, but it would also help for the future if some documents on MISRA 2004 exist.

Thanks for Help,

NM

Print this item

  MISRA Autocode Public Review
Posted by: david ward - 08-12-2006, 12:17 PM - Forum: Announcements - No Replies

MISRA has been developing a set of guidelines for users of control system modelling packages. The aim of the guidelines is to provide a set of rules, in a similar fashion to the MISRA C rules, which encourage good modelling practices and avoid poorly-defined features of the modelling language. In light of automotive industry trends, some rules will be aimed at the use of automatic code generators in safety-related systems.

Following the initial activities of this Working Group, MISRA is pleased to announce that drafts of the first documents will be available in the new year for public comment. These documents are:

  • MISRA SLSF - guidelines for users of Simulink and Stateflow
  • MISRA TL - guidelines for users of Targetlink
  • MISRA ACG - guidelines for compliance with MISRA C in automatically-generated code
If you are prepared to receive one or more of these documents for review, please visit the MISRA website to download a reply form and return by post or fax to MIRA. As this form requires a signature to indicate acceptance of the terms, only fully completed and signed copies can be accepted.

Print this item

  MISRAC Rules
Posted by: prabhakarp - 21-11-2006, 10:51 AM - Forum: MISRA-C:1998 to MISRA-C:2004 migration - No Replies

hello all,

can you anyone provide me some documents related to MISRA C rules

thanks

Print this item

  Underlying type of character constants and \"plain char
Posted by: Shane Swenson - 15-11-2006, 12:40 AM - Forum: 6.10 Arithmetic Type Conversions - Replies (4)

We're wondering if rule 10.1 applies to character constants and the \"plain char\" type, and, if so, what their underlying types are. For example,

Code:
char_t c1 = 'a';
char_t c2 = 'abc';
From the discussion in 6.10.4, we expect that the underlying types of 'a' and 'abc' are 8 bit signed and 32 bit signed, respectively, on a target with 8 bit chars.

The underlying types of c1 and c2 are less clear. We could treat \"plain char\" similarly to signed char or unsigned char based on the implementation's signedness of \"plain char\", or from the discussion following rules 6.1 and 6.2, we could deduce that \"plain char\" is distinct from signed char and unsigned char with respect to rule 10.1.

If rule 10.1 applies to character constants, we expect that the assignment to c2 violates rule 10.1 because it probably requires a conversion of the character constant to a narrower type. If the \"plain char\" type is unsigned on the target system, the assignment to c1 could be considered as violating rule 10.1 because it requires a conversion from a signed type to an unsigned type.

If the \"plain char\" type is considered distinct from the signed char and unsigned char types, both assignments would violate rule 10.1 unless the underlying type of a character constant is also \"plain char\", though this also seems problematic since, for example, the plain char type usually can't represent the value 'abc'.

What are the Committee's positions on these issues?

Print this item

  18.4 Unions shall not be used...
Posted by: rahul_mishra - 13-11-2006, 12:58 PM - Forum: 6.18 Structures and Unions - Replies (1)

Is it that unions can be declared or defined but not used? i.e.; Do we need to flag a violation even on the declaration or definition of the union? or is it only on the usage of it.

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,309
» Latest member: 1fuhd
» Forum threads: 1,066
» Forum posts: 2,933

Full Statistics

Online Users
There are currently 91 online users.
» 0 Member(s) | 86 Guest(s)
Bing, DuckDuckGo, Facebook, Google, UptimeRobot

Latest Threads
13.2 Was TC2 correctly ap...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:47 PM
» Replies: 1
» Views: 624
20.12 Does the stringific...
Forum: 8.20 Preprocessing directives
Last Post: misra-c
08-10-2026, 12:40 PM
» Replies: 1
» Views: 554
13.3 Should side effects ...
Forum: 8.13 Side effects
Last Post: misra-c
08-10-2026, 12:37 PM
» Replies: 1
» Views: 425
11.6 pointer to pointer t...
Forum: 8.11 Pointer type conversions
Last Post: misra-c
08-10-2026, 12:21 PM
» Replies: 2
» Views: 1,031
What is the UTLR of -1?
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 12:15 PM
» Replies: 1
» Views: 597
10.3 Clarify if narrower ...
Forum: 8.10 The essential type model
Last Post: misra-c
08-10-2026, 11:57 AM
» Replies: 1
» Views: 508
It 8.12 intended to be so...
Forum: 8.8 Declarations and defnitions
Last Post: misra-c
08-10-2026, 11:50 AM
» Replies: 1
» Views: 455
Rule 0.1.1 Example f4
Forum: 4.0 Language independent issues
Last Post: cgpzs
07-10-2026, 11:07 AM
» Replies: 3
» Views: 717
Rule 6-2-2 Usage of std::...
Forum: 6.6 Statements (C++)
Last Post: misra cpp
25-09-2026, 05:43 PM
» Replies: 1
» Views: 434
M5-0-4 switch over unscop...
Forum: 6.5 Expressions (C++)
Last Post: misra cpp
25-09-2026, 01:00 PM
» Replies: 3
» Views: 532