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

Username
  

Password
  





  "char" vs. "signed char" vs. "unsigned char" in rule 10.5
Posted by: andersl - 01-02-2010, 11:00 AM - Forum: 6.10 Arithmetic Type Conversions - Replies (4)

In C, there are three types of characters: "char", "signed char", and "unsigned char". (The representation of the type "char" is either signed or unsigned). Note that this makes characters different than the other integer types as, for example, "short" is a synonym for "signed short".

Rule 10.5 states "if the bitwise operators ~ and

Print this item

  IEC 26262
Posted by: ggentile - 31-01-2010, 07:38 PM - Forum: MISRA AC GMG discussions - Replies (7)

Hi Board,

exist any relation/ raccamandation in IEC 26262 to follow the new MISRA AC rules ?

Thanks Giacomo

Print this item

  Rule 10.5 clarification
Posted by: c-addison - 30-12-2009, 10:09 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (5)

The description of rule 10.5 mentions that the operators must be applied to "small integer types" for the casts to be required. The types unsigned char and unsigned short are mentioned explicitly. What if char, short, and int are all the same size on the machine? In that case is OK to not perform the required cast? This really comes down to whether or not we should be checking for the unsigned char and unsigned short types explicitly or instead should check for all types which have a a narrower type than int.

Print this item

  switch
Posted by: ggentile - 08-12-2009, 08:23 PM - Forum: MISRA AC SLSF discussions - Replies (1)

It seems to me that any restriction are applied to switch block.

Is admited to switch between differnt type of signal:
float/boolena
int/bool
int/float

Instead GMG rules suggest the user to use types properly.

Giacomo

Print this item

  wrong use of type float
Posted by: ggentile - 08-12-2009, 08:19 PM - Forum: MISRA AC SLSF discussions - Replies (1)

I didn't found any explicit rule that prohibit a misleading use of float

1) float as vector index into stateflow/simulink
2) logical operation between float in stateflow and simulink

General Modelling rules cover this topic but SLSF seems to me not!

May you confirm that I've properly read the standard ?

Giacomo

Our concern is also related to unoptimized code that should be produce by these bad modelling style

Print this item

  Violations of rules 11.1, 11.2, 11.3, 11.4
Posted by: adytzul_ac - 25-11-2009, 12:40 PM - Forum: 6.11 Pointer Type Conversions - Replies (5)

Hello.
My PC-LINT tool gives me an error of violating of rules 11.1, 11.2, 11.3, 11.4 (cast from unsigned char to pointer ) on the line 2:

line 1: unsigned char* ptr;
line 2: ptr=(unsigned char*)0x12;

The idea behind is that I want to initialize a pointer with a non-zero address in a MISRA-compliant style.

Thank you for the answer.

Best regards.

Print this item

  2 questions for rule 18.1
Posted by: pmhill - 25-11-2009, 09:22 AM - Forum: 6.18 Structures and Unions - Replies (2)

The rule applies to structure definitions that are incomplete, but I see from exemplar suite file mc2_1801.c the following unexpected violation:

struct {
int8_t a;
int8_t b [ ]; /* Not Compliant - constraint error 6.5.2.1 */
} mc2_1801_st = { 1, { 2, 3, 4 } };

Are you including as "incomplete" any structure that has a flexible array member?

Apart from this, what other coding practice is left that might cause a problem?

If the type is incomplete, a compile error will result from any attempt to create an object of that type or refer to its members or to compute sizeof, etc.

So I cannot think of any legal C code that would be a violation of this rule.

Print this item

  Rule 3-1-1 and constant declarations
Posted by: MarkCotton - 18-11-2009, 06:08 PM - Forum: 6.3 Basic concepts (C++) - Replies (2)

I have been using PCLint to analyse code which have constants defined in header files e.g.

const uint8 PLD_READ_VERIFICATION_BYTE_4 = 7;

PCLint claims that this violates rule 3-1-1. Is this a true interpretation of this rule or are constants permitted in header files?

Mark.

Print this item

  Rule 3.6: Supplied Libraries Compliance Check
Posted by: MichelCampmas - 16-11-2009, 06:21 PM - Forum: 6.3 Documentation - Replies (1)

We are using an ARM development suite where standard libraries are provided with the tool suite. Looking at the MISRA rules, I found quite a few which prohibit using such and such function (atoi, etc...). Which means that implicitly, the other functions can be used.
However, rule 3.6 requires that all libraries (including the ones provided with the compiler) be "subjected to appropriate validation".
Could you expand on what this means in regards to standard libraries? Do we need to require the vendor to certify he is MISRA compliant? If not possible, does this means we have to write our own version, so that we are sure it is compliant?
Thanks
Michel Campmas
Cypress Semiconductor

Print this item

  Is below code is compliant to rule 10.1?
Posted by: Pundlik Oulkar - 11-11-2009, 05:15 AM - Forum: 6.10 Arithmetic Type Conversions - Replies (1)

//Example 1:

struct xyz {
unsigned char bit:1;
}abc={0} ; // Is this assignment to bit-field is compliant to MISRA rule10.1 and Why?

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 136 online users.
» 0 Member(s) | 132 Guest(s)
Bing, 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: 427
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,032
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: 722
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: 436
M5-0-4 switch over unscop...
Forum: 6.5 Expressions (C++)
Last Post: misra cpp
25-09-2026, 01:00 PM
» Replies: 3
» Views: 534