Page 1 of 1

Plain chars within structs?

Posted: Thu Mar 18, 2010 3:53 pm
by gs
The commentary for rule 6.1 and 6.2 states
The permissible operators on plain char types are the simple assignment operator (=), equality operators (==, !=) and explicit casts to integral types. Additionally, the second and third operands of the ternary conditional operator may both be of plain char type.
What about the '.' operator? Or the '->' operator? Could not an object of structure type contain a plain char member, making that member the second operand of the operator?

What about bit addressing or sizeof?

Re: Plain chars within structs?

Posted: Wed Mar 24, 2010 5:02 pm
by gs
Or taking the address of a plain char object?

Re: Plain chars within structs?

Posted: Thu Mar 25, 2010 6:39 am
by jbezem
Using . or -> or & on a variable is IMHO not an operation on the _value_ of that variable (or struct member, so it's in a different category. Maybe the wording should be more clear that assignment and comparison (for instance) are operating on the values, the address operator is providing meta-information (the address, not the value), and . and -> are providing meta-information on the struct.

FWIW,

Johan

Re: Plain chars within structs?

Posted: Tue Apr 06, 2010 8:19 pm
by gs
Perhaps; however, the wording of the guidelines state:
The permissible operators on plain char types are the simple assignment operator ...
(Emphasis added.) The guidelines do not appear to limit the restriction to values; hence, my confusion.

Re: Plain chars within structs?

Posted: Thu May 13, 2010 9:44 am
by misra-c
Neither '.' nor '->' operates on char type even though they may yield a result of char type. Therefore they are both permitted by Rules 6.1 and 6.2.

The supporting text restricts operations on char type to assignment, equality, conditional operations and certain type-casts. The sizeof and & operators should also have appeared in this list of permitted operations.