Mixing plain char and non-plain char within ?:

6.6 Types

Moderators: misra-c, david ward

Post Reply
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

Mixing plain char and non-plain char within ?:

Post by gs » Wed Mar 24, 2010 2:03 pm

The commentary for rules #6.1 and #6.2 state,
[T]he second and third operands of the ternary conditional operator may both be of plain char type.
Do these rules permit one of these two operands to have plain char type and the other to have signed char or unsigned char type?

For that matter, what about the mixing of such operands with operators considered acceptable for use with objects of plain char type? For example, do the rules permit the following:

Code: Select all

void function( char a, signed char b )
    if( a == b )
        { /*  do something  */ }

Posts: 572
Joined: Thu Jan 05, 2006 1:11 pm

Re: Mixing plain char and non-plain char within ?:

Post by misra-c » Thu May 13, 2010 10:12 am

These rules do not preclude operating on a mixture of plain char and signed/unsigned char types using assignment, equality or conditional operators. However, this is not recommended and is likely to be precluded in a future revision of the MISRA C Guidelines.
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “6.6 Types”