Re: shame on MISRA



Marcin Wolcendorf wrote:
On Mon, 23 Apr 2007 06:47:55 -0700, Robert Adsett wrote:
Marcin Wolcendorf <wolce...@xxxxxxxxxxxxxx> wrote:

.... snip ...

Yeah, now I can. It just doesn't matter. If I use ~0U it will
trigger MISRA-C rule 10.1 (An integer constant expression with
negative value is

Maybe I'm being exceptionally dense this morning but What integer
constant expression with a negative value?

Well, having ~0U is not quite enough; I want to use it :). So I
did: uint16_t some_variable = (uint16_t)(~0U);
(effectively- all #defines, ...) to have 0xffff in some_variable.
It was enough to trigger the rule.

Ignoring Misra, that is not as accurate as "unsigned = -1", which
will set all bits to one everywhere.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline.net



--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: shame on MISRA
    ... constant expression with a negative value? ... when the underlying code doesn't in fact depend on having an unsigned 16 ...
    (comp.arch.embedded)
  • Re: shame on MISRA
    ... MISRA-C rule 10.1 (An integer constant expression with negative value is ... It is a better way- logical operators ...
    (comp.arch.embedded)
  • Re: shame on MISRA
    ... I can't recall the reason, ... MISRA-C rule 10.1 (An integer constant expression with negative value is ... I still don't see an integer constant expression with a negative value. ...
    (comp.arch.embedded)
  • Re: EXIT_SUCCESS guaranteed to always be zero?
    ... > To imply that EXIT_SUCCESS (integer constant expression ... constant expression, but the value of that expression is undefined. ... at least some versions of VMS C defined EXIT_SUCCESS ... not to use numeric arguments to exit() other than 0. ...
    (comp.lang.c)