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

Username
  

Password
  





  Casting integer to floating point
Posted by: bobvanderputten - 04-10-2016, 12:46 PM - Forum: 6.10 Arithmetic Type Conversions - Replies (2)

I have the following code:

int16_t int_torque_I_MUL;
float32_t f_temp1;
...
f_temp1 = (float32_t)(int_torque_I_MUL);
...
The above will generate:
MISRA-C:2012 R.10.1,R.10.3,R.10.4,R.10.5,R.11.1: Value is not of appropriate type. : (double and short)
But I don't understand why??
How can I cast a signed 16 bit integer to a double (float32_t )?

Print this item

  Rule 4-5-1 prohibits 'b1 |= b2;' ?
Posted by: grunwald - 28-09-2016, 02:00 PM - Forum: 6.4 Standard conversions (C++) - Replies (3)

Neither `|` nor `|=` is listed as allowed operator.
Does this mean the following code a violation of Rule 4-5-1?

Code:
bool b1 = false;

void f(int x)
{
    b1 |= (x == 0);
}

Print this item

  Rule 0-1-9
Posted by: dg1980 - 28-09-2016, 12:52 PM - Forum: 6.0 Language independent issues (C++) - Replies (1)

Please add an explicit exception for static_assert if the next MISRA C++ version allows C++11.
Thanks.

Print this item

  Rule 5-0-19 are references also considered a 'pointer indirection'?
Posted by: grunwald - 23-09-2016, 03:45 PM - Forum: 6.5 Expressions (C++) - Replies (1)

More concretely, is the following code a violation?

Code:
typedef void **my_t;

void f(my_t& x)
{
   x = NULL;
}

Print this item

  Synchronization with MISRA C 2012
Posted by: dg1980 - 21-09-2016, 12:27 PM - Forum: 6.18 Language support library (C++) - Replies (1)

Dear MISRA team,

i recently stumbled upon Rule 21.9 of MISRA C 2012 which prohibits use of bsearch/qsort.
Currently, there is no equivalent in MISRA C++ 2008, so it would be legal to use bsearch/qsort in C++ (if you use cstdlib that is).
Maybe this is another synchronization topic for the next version of the standard (along with the preprocessor usage, see https://misra.org.uk/forum/viewtopic.php...1549#p3031).
Thanks.

Print this item

  Rule 5-0-12
Posted by: dg1980 - 15-09-2016, 12:53 PM - Forum: 6.5 Expressions (C++) - Replies (2)

From the official text:

Code:
uint8_t b = '\r';//Non-compliant, explicitly unsigned
Would a static_cast turn this into a compliant statement?
Code:
uint8_t b = static_cast('\r');//Compliant
Static analysis tool used says yes, hence the question.

Print this item

  Does Rule 11.9 allow indirect expansion from NULL?
Posted by: rgamble - 14-09-2016, 02:23 PM - Forum: 8.11 Pointer type conversions - Replies (3)

Does the following example violate Rule 11.9?

Code:
#define FOO NULL
int32_t *p1 = FOO;

Print this item

  Rule 3.1 - Hyperlinks in comments?
Posted by: Andrew Banks - 02-09-2016, 11:00 AM - Forum: 8.3 Comments - Replies (2)

Cross-post from the MISRA C/C++ LinkedIn group

Quote:Is there any chance MISRA could alter Rule 3.1 to allow common hyperlinks in C comments such that a Deviation isn't required:

Code:
/*
* See https://somewhere.over.the.rainbow/way/up/high.htm
*/

I use direct references to RFCs in source files that allow clicking in Visual Studio to open up a browser at the relevant spec. MISRA sees this as evil. If https: or http: occurs before //, then there isn't much confusion about commenting...

The (perfectly sound) Rationale for the Rule is to detect missing */ comment terminators.

There is already an Exception to permit // within a */ comment... so a further Exception to permit hyperlinks of the form http://, https://, ftp:// or ftps:// (without requiring a Deviation) seems reasonable?

Print this item

  Directive 4.5
Posted by: dg1980 - 01-09-2016, 11:59 AM - Forum: 7.4 Code design - Replies (1)

Dear MISRA team,

please read the text carefully and then read MISRA C++ 2008 Rule 2-10-1.
It is virtually identical but in C++ it is rated required and in C it is rated advisory.
Was that a change on purpose or an accident?
Thanks.

Print this item

  Rule 1.3 - What do people do to check this rule?
Posted by: delta_controls - 23-08-2016, 02:04 PM - Forum: 8.1 A standard C environment - Replies (13)

Hi,

Of the 191 undefined behaviours listed in C99, there are 61 that have no associated MISRA guideline. Checking all of these is particularly labourious, especially as the list in Annex J is not numbered.

How do people go about checking conformity with this catch-all rule?

Does anyone globally deviate from this rule, since the most important and most likely behaviours are addressed by other guidelines and checking the others is not practical?

Thanks.

Print this item

Search Forums

(Advanced Search)

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

Full Statistics

Online Users
There are currently 151 online users.
» 0 Member(s) | 148 Guest(s)
Bing, Google, 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: 167
A3-3-2 Contradictory exam...
Forum: AUTOSAR C++:2014 rules
Last Post: cgpzs
31-03-2025, 09:30 AM
» Replies: 2
» Views: 296
16.6.1 clarification
Forum: 4.16 Overloading
Last Post: cgpzs
31-03-2025, 09:29 AM
» Replies: 2
» Views: 277
Rule 9.3.1 - iteration st...
Forum: 4.9 Statements
Last Post: misra cpp
28-03-2025, 01:17 PM
» Replies: 1
» Views: 186
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: 206
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: 164
Adopted modal expressions...
Forum: General Questions
Last Post: Yordan Naydenov
17-03-2025, 09:01 AM
» Replies: 0
» Views: 258
Roadmap to c23 support
Forum: General Questions
Last Post: ACHart
28-02-2025, 03:23 PM
» Replies: 0
» Views: 211
Rule 6.2.1 weak linkage
Forum: 4.6 Basic concepts
Last Post: misra cpp
28-02-2025, 01:04 PM
» Replies: 1
» Views: 266
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: 691