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

Username
  

Password
  





  0-1-8. Exception: empty interface function.
Posted by: Alex-R - 18-11-2013, 01:55 PM - Forum: 6.0 Language independent issues (C++) - Replies (4)

0-1-8:
The following are examples of external side effects:
• Reading or writing to a ile, stream, etc.;
• Changing the value of a non local variable;
• Changing the value of an argument having reference type;
• Using a volatile object;
• Raising an exception.


Situation:
There is some mouse interface: OnMouseUp, OnMouseDone, OnMouseMove... or some other manipulator interface... does not matter...
There are some objects that use this interface but not all objects need all functions, so it is possible:
void SomeObject::OnMouseMove ( uint32 x, uint32 y)
{
//do nothing
}

Print this item

  Rules 0-1-3, 0-1-4, 0-1-5 and 0-1-8. External libs.
Posted by: Alex-R - 18-11-2013, 01:17 PM - Forum: 6.0 Language independent issues (C++) - Replies (1)

Rules 0-1-3, 0-1-4, 0-1-5 and 0-1-8 could have exception as using external libs.
The could be include external lib header or involved lib external sources that have more functionality than uses the project.

Yes?

Print this item

  the definition of distinct
Posted by: Takafumi Wakita - 18-11-2013, 06:18 AM - Forum: 8.5 Identifers - Replies (1)

Hello,

in the Rule 5.1, 5.2, 5.3, 5.4 and 5.5.

When portability is not our concern:

Can we use the implementation defined limits for the definition of distinct?

Best regards,
Takafumi Wakita

Print this item

  Is it possible to right shift a signed variable? (12.7)
Posted by: jbrookley - 29-10-2013, 06:01 PM - Forum: 6.12 Expressions - Replies (2)

Hello everyone,

I have an application that I need to right shift a signed variable but it seems to be giving me some issues. My initial line was:

Code:
typedef unsigned char uchar8;
typedef signed long slong32;

slong32 Shifted Long;
uchar8 NumBitsShift;

ShiftedLong >>= NumBitsShift - 1u;

Due to various MISRA C requirements, the code has morphed into this ridiculous block:

Code:
typedef unsigned char uchar8;
typedef signed char schar8;
typedef signed long slong32;

slong32 Shifted Long;
uchar8 NumBitsShift;
uchar8 tempchar = 0;
slong32 templong = 0;

tempchar = (uchar8)(NumBitsShift - 1u);

if((tempchar>=1u)&&(tempchar> tempchar; /* MISRA C 12.7 Error here */
}

On the flagged line, I get the error "Underlying type of LHS operand bitwise operator is signed type: ShiftedLong". I've tried fixing that by casting the tempchar as shown below:

Code:
ShiftedLong = ShiftedLong >> (slong32)tempchar;

I even tried to go completely over the top with plans to scale it back once I isolate the problem by doing this:

Code:
ShiftedLong = (slong32)((slong32)ShiftedLong >> (slong32)tempchar);

It appears, I am still having the same problem. What it now appears, based on this, is that it is not possible to right shift a signed variable. Is this true or is there a way around this?

Any help you can give me would be appreciated. Thanks!

Print this item

  Circular logic with rule 12.1
Posted by: jbrookley - 28-10-2013, 10:30 PM - Forum: 6.12 Expressions - Replies (4)

Hello,

I had a violation for rule 10-5 (the result of a

Print this item

  Last example for rule #13.6?
Posted by: gs - 28-10-2013, 05:55 PM - Forum: 8.13 Side effects - Replies (1)

Try as I might, I cannot get my compiler to recognize the last example for rule #13.6, the example involving an array of function pointers, as well formed. Is this intended?

Print this item

  Does 11.4 apply to any pointer or just object pointers?
Posted by: rgamble - 25-10-2013, 04:17 PM - Forum: 8.11 Pointer type conversions - Replies (2)

The scope of Rule 11.4 is unclear. The headline text for Rule 11.4 uses the phrase "pointer to object", the amplification just uses "pointer", and the rationale uses both phrases. Is this rule intended to apply to pointers to functions and pointers to incomplete types? In other words, are the following violations of this rule?

Code:
void *vp        = 1;
int (*fp)(void) = 1;

If the answer is "yes", then does the exception for null pointer constants (which also uses the phrase "pointer to object") apply to all pointers or just pointers to objects? E.g.:

Code:
int *ip         = 0;  // Okay, allowed by exception
void *vp        = 0;  // Okay?
int (*fp)(void) = 0;  // Okay?

Print this item

  Rule 12.4 - Do not use expressions with side effects
Posted by: jbrookley - 24-10-2013, 10:17 PM - Forum: 6.12 Expressions - Replies (3)

Hello everyone,

I am having a problem with rule 12.4 (Do not use expressions with side effects in the right hand operand of a logical '&&' operator). My code is as follows:

[code]if ((DualDAC == 0) && (ADC1Flag

Print this item

  MISRA2004-12_7-3 - Underlying type of LHS operand
Posted by: jbrookley - 17-10-2013, 11:29 PM - Forum: 6.12 Expressions - Replies (6)

I'm currently using Parasoft's C++ Test program and it's flagging the last line of the code below and I'm not seeing the error . . . "The error I'm getting is Underlying type of LHS operand of bitwise operator is signed type." Below is the code:

[code]typedef signed short sshort16;

struct DACStruct
{
sshort16 Off;
};

struct DACStruct DACData;

DACData.Off = (sshort16)(EEPROM_BANK1[1]) + (((sshort16)(EEPROM_BANK1[0]))

Print this item

  Examples in 6.5.3 do not match definition of a loop-counter
Posted by: drstaiger - 14-10-2013, 10:16 AM - Forum: 6.6 Statements (C++) - Replies (5)

A loop counter is defined as loop control variable that is, among other conditions,

Quote:© modified in expression

The examples for rule 6-5-3 state:
Code:
for (x = 0; modify(&x); ) // Non-compliant
{
}
for (x = 0; x < 10; )
{
  x = x * 2; // Non-compliant
}
But in both cases x is not a loop counter due to condition © being not satisfied (the expression is empty, no modification of x here), and thus the rule's text is not violated.
Should the examples be changed to contain a ++x in the expression?

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,207
» Latest member: wandamfonseca
» Forum threads: 1,017
» Forum posts: 2,796

Full Statistics

Online Users
There are currently 116 online users.
» 0 Member(s) | 113 Guest(s)
Applebot, Bing, 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: 178
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 309
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 293
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 194
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: 214
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: 175
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 276
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 219
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 274
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: 702