Rule 5.1 and case-sensitive

Moderators: misra-c, david ward

Post Reply
xiangke
Posts: 9
Joined: Tue Apr 11, 2017 7:34 am
Company: valeo

Rule 5.1 and case-sensitive

Post by xiangke » Mon Jun 12, 2017 4:25 am

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 ?

swestin
Posts: 8
Joined: Wed May 28, 2014 6:53 pm
Company: GrammaTech Inc.

Re: Rule 5.1 and case-sensitive

Post by swestin » Wed Jun 14, 2017 4:47 pm

> 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)

xiangke
Posts: 9
Joined: Tue Apr 11, 2017 7:34 am
Company: valeo

Re: Rule 5.1 and case-sensitive

Post by xiangke » Fri Jul 14, 2017 4:32 am

Yes, You are right, I verify this point.The example comply with Rule 5.1 (distinctness), but violate Directive 4.5 (typographical ambiguity).

misra-c
Posts: 560
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 5.1 and case-sensitive

Post by misra-c » Thu Sep 21, 2017 10:13 am

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.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.5 Identifers”