File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
cpp/misra/test/rules/RULE-7-0-5 Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -236,4 +236,24 @@ void test_pointer_assignment_arithmetic() {
236236 l5 -= l2; // COMPLIANT - rule does not apply to pointer arithmetic
237237 l5 -= l3; // COMPLIANT - rule does not apply to pointer arithmetic
238238 l5 -= l4; // COMPLIANT - rule does not apply to pointer arithmetic
239- }
239+ }
240+
241+ #define A 100LL // intmax_t
242+ #define B 200LL // intmax_t
243+ #define C 300ULL // uintmax_t
244+ #define D 400ULL // uintmax_t
245+
246+ #if A + B > 250 // COMPLIANT - both intmax_t, no conversion
247+ ;
248+ #elif C + D < 800 // COMPLIANT - both uintmax_t, no conversion
249+ ;
250+ #endif
251+
252+ #define SIGNED_MAX 9223372036854775807LL // intmax_t
253+ #define UNSIGNED_VAL 1ULL // uintmax_t
254+
255+ #if SIGNED_MAX + UNSIGNED_VAL > 0 // NON_COMPLIANT[FALSE_NEGATIVE]
256+ // intmax_t + uintmax_t → both converted to uintmax_t
257+ // This changes SIGNED_MAX from signed to unsigned
258+ ;
259+ #endif
You can’t perform that action at this time.
0 commit comments