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

Username
  

Password
  





  Is there any MISRA rule to find this sideeffect??
Posted by: sprabhakars - 03-08-2018, 12:02 PM - Forum: 8.13 Side effects - Replies (6)

I am not sure, if this potential problem is categorized under any MISRA rules??

Code:
#include
static unsigned short var2;
int main()
{
       unsigned char var1 = 0;

       while (var1 <  var2)
       {
          var1++;
       }
       (void)printf("program completed \n ");
       return 0;
}

The variable var2 can have some value updated outside this function(may be more than 256) and causing a system crash as the while condition never fails.

I run this with PC-Lint and Parasoft's MISRA checker, both doesn't find any error with this portion of code.

Print this item

  HIS Subset of MISRA
Posted by: [email protected] - 27-07-2018, 07:17 PM - Forum: General Questions - Replies (4)

Dear colleagues,
I am trying to find in the web the MISRA subset for HIS with no success.
Does anybody know where it is possible to get these files / list of rules?

Thanks in advance,

Ricardo

Print this item

  Rule 3-4-1 and defining constants in one place
Posted by: rrosier - 26-07-2018, 12:28 PM - Forum: 6.3 Basic concepts (C++) - Replies (3)

If one were to use the strategy of defining all the constants used within a file at the top of the file, either as static const or in an unnamed namespace, but some of the constants are used in multiple places and others are only used in single places, then those that are only used in single places will violate Rule 3-4-1.

If those that are used only in single places are subsequently moved into blocks with reduced scope, then the constants are scattered around the file.

This could create a maintenance headache because it is more difficult for a developer to find a constant.

Furthermore, if a developer needs to use a singly-used constant now in another place, they might not realise that the constant has already been defined (and then widen its scope) but instead add in a new singly-used constant of reduced scope in the new place.

It there some way to put all of the defined constants into a well-known location, but then not violate Rule 3-4-1 for the singly-used ones?

Print this item

  Memory allocation when throwing an exception.
Posted by: apasternak - 24-07-2018, 12:15 PM - Forum: 6.15 Exception handling (C++) - Replies (1)

Dear all

While doing a memory audit of our framework for autonomous driving cars we realized that throwing any kind of exception dynamically allocates memory on compilers using the Itanium C++ ABI (notably gcc and clang). Further, throwing an exception may block for which is not acceptable for safety-critical real-time systems.

Neither Misra 2008 nor Autosar 14 or other guidelines forbid exceptions in safety-critical environments. What were the considerations when investigating this issue?

To solve this issue we created a library which replaces the dynamic memory allocation with a memory pool. This library is freely available here: https://github.com/ApexAI/static_exception

Any inputs or other approaches would be very welcome!

Best regards,

Andreas

Print this item

  3-9-2 and auto in future MISRA C++14
Posted by: dg1980 - 20-07-2018, 07:32 AM - Forum: 6.3 Basic concepts (C++) - Replies (3)

Hi,

as stated here (https://misra.org.uk/forum/viewtopic.php...1504#p3404) the next version of MISRA C++ will be based on ISO C++14.
I am curious if you already came to a decision on whether to allow or prohibit the auto keyword for automatic type deduction?
While it is certainly more convenient to write code, i would imagine performing a code review or adapting a static analysis tool would become more challenging.

Print this item

  Rule 10.1
Posted by: phdenis - 18-07-2018, 09:30 AM - Forum: 6.10 Arithmetic Type Conversions - Replies (4)

Hello all,

I've an error 10.1 on the following C code:

Code:
#define MyConst 0x8A

My Code Review checker asks to add a U to the constant.

I'm quite surprised if it was a decimal value, I'll understand it but for an hexa, I don't really understand why ?

Another question is to know if a test set is present on the MISRA community to check the correct behaviour of the Code Review tool.

By advance thanks for your help.

B/R
Philippe

Print this item

  MISRA C++ new version
Posted by: ptalwar - 13-07-2018, 09:15 PM - Forum: C++ Announcements - Replies (8)

Is MISRA going to release a new version for C++14 anytime soon?
If so, what does the timeline look like and when it's going to be made available to public?

Print this item

  Why is rule 1.2 classified as undecidable?
Posted by: dg1980 - 13-07-2018, 06:31 AM - Forum: 8.1 A standard C environment - Replies (1)

All you have to do is check the syntax/keywords against the C language standard?
It is even possible with some compilers (e.g. a strict mode)?

Print this item

  5-2-7 and void pointer conversions
Posted by: rgamble - 13-07-2018, 02:32 AM - Forum: 6.5 Expressions (C++) - Replies (1)

Are conversions between pointers to void and pointers to object types a violation of rule 5-2-7? It isn't clear what "object with pointer type" means here (or "unrelated pointer type" for that matter). Specifically, are either of the casts below a violation of Rule 5-2-7?

Code:
void bar(int *ip, void *vp) {
    ip = static_cast(vp);
    vp = static_cast(ip);
}

Print this item

  Conversions outside of the essential type categories
Posted by: gdavis - 10-07-2018, 11:26 PM - Forum: 8.10 The essential type model - Replies (1)

Hello,

With respect to the essential type rules, do conversions to types that are outside the essential type categories count as violations of the rules? For example:

Code:
#include
char buf[80];
char *p = buf;
uintptr_t p_plus_one;
void foo(void);
void foo(void) {
    // This next statement violates R11.4.  But does
    // it violate R10.8?  As a pointer type, p+1 does not
    // have a clear essential type category.
    p_plus_one = (uintptr_t)(p+1);
}
On the one hand, the spirit of the rule seems like it should prohibit such things. On the other hand, TC1 amends rule 10.1 to describe how a pointer type may not be used as an operand of a logical operator.

Thank you for your time.

-Greg

Print this item

Search Forums

(Advanced Search)

Forum Statistics
» Members: 6,171
» Latest member: stephanmuench
» Forum threads: 998
» Forum posts: 2,752

Full Statistics

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

Latest Threads
Rule 6.2.1: non-inline co...
Forum: 4.6 Basic concepts
Last Post: cgpzs
Yesterday, 10:11 AM
» Replies: 0
» Views: 18
Rule 0.1.2
Forum: 4.0 Language independent issues
Last Post: stephanmuench
21-11-2024, 01:12 PM
» Replies: 0
» Views: 30
A18-9-4
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
23-10-2024, 12:04 PM
» Replies: 2
» Views: 354
A8-4-5: are partial moves...
Forum: AUTOSAR C++:2014 rules
Last Post: misra cpp
22-10-2024, 02:03 PM
» Replies: 1
» Views: 315
model information blocks ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:27 PM
» Replies: 1
» Views: 4,436
MISRA AL SLSF - Rule 043I
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
22-10-2024, 01:11 PM
» Replies: 1
» Views: 8,852
MISRA AC EC guidelines
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:21 AM
» Replies: 4
» Views: 15,478
News on future releases
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 08:05 AM
» Replies: 1
» Views: 5,680
Signal naming convention ...
Forum: MISRA AC SLSF discussions
Last Post: misra-ac
21-10-2024, 07:57 AM
» Replies: 1
» Views: 7,233
Rule 7.0.2: operator cons...
Forum: 4.7 Standard conversions
Last Post: karos
14-10-2024, 08:52 PM
» Replies: 2
» Views: 417