MISRA Discussion Forums

Full Version: Rule 5.1 and case-sensitive
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Have a short description in example section of Rule 5.1:
In the following non-compliant example, the implementation supports 6 significant case-insensitive characters in external identifiers. The identifiers in the two translation units are different but are not distinct in their significant characters.
/* file1.c */ int32_t abc = 0;
/* file2.c */ int32_t ABC = 0;

Have another description
In the following example, the definitions all occur in the same translation unit. The implementation in question supports 31 significant case-sensitive characters in external identifiers.
/* 1234567890123456789012345678901********* Characters */
int32_t engine_exhaust_gas_temperature_raw;
int32_t engine_exhaust_gas_temperature_scaled; /* Non-compliant */

Case-sensitive is mentioned here, I think it means that the following case is compliant
/* file1.c */ int32_t abc = 0;
/* file2.c */ int32_t ABC = 0;

is it inconsistent? case-sensitive is implemented or supported for this rule ?
> is it inconsistent? case-sensitive is implemented or supported for this rule ?

I believe the example you quote would comply with Rule 5.1 (distinctness), but violate Directive 4.5 (typographical ambiguity)
Yes, You are right, I verify this point.The example comply with Rule 5.1 (distinctness), but violate Directive 4.5 (typographical ambiguity).
The definition of the word "distinct" in rule 5.1 depends on the implementation in which the code is being compiled/linked.
What is considered non-compliant with this rule will depend on the implementation under which the code is being developed, not the implementation of the analysis tool.

The first example in the document (engine_exhaust_gas_temperature_raw) assumes an implementation which supports:
  • 31 significant characters
  • case-sensitive
The second example (abc) assumes an implementation which supports:
  • 6 significant characters
  • case-INsensitive
Because this implementation is case-insensitive, the linker may treat "abc" and "ABC" as the same identifier. Therefore this is non-compliant with rule 5.1.

"abc" v "ABC" would be compliant with rule 5.1 if the implementation treated external identifiers as being case-sensitive.

Note: "abc" and "ABC" will always be non-compliant with directive 4.5.