#4319 Regression test chekedint does not test ckd_mul

open
nobody
None
other
5
1 hour ago
1 hour ago
No

The file support/regression/tests/checkedint.c.in checks for ckd_add even when comparing against mul_func.

    l = 1;
    r = 2;
    ASSERT ((mul_func (l, r) != (signed long long)l * r) == ckd_add (&result, l, r));
    l = 100;
    r = 200;
    ASSERT ((mul_func (l, r) != (signed long long)l * r) == ckd_add (&result, l, r));

replacing ckd_add with ckd_mul generates several warnings when running the suite.

cases/checkedint/checkedint_type_unsigned_char.c:52: warning 244: pointer types incompatible 
from type 'unsigned-char near* fixed'
  to type 'unsigned-long-int generic* auto'
cases/checkedint/checkedint_type_unsigned_char.c:55: warning 244: pointer types incompatible 
from type 'unsigned-char near* fixed'
  to type 'unsigned-long-int generic* auto'

the cause of this is the extra case for unsigned long calling __ckd_mul_ulongull

#define ckd_mul(r, a, b) \
  _Generic ((a), \
  signed long long: __ckd_mul_unimplemented(r, a, b), \
  unsigned long long: __ckd_mul_unimplemented(r, a, b), \
  unsigned long: \
    _Generic ((b), \
    signed long long: __ckd_mul_unimplemented(r, a, b), \
    unsigned long long: __ckd_mul_unimplemented(r, a, b), \
    unsigned long: __ckd_mul_ulongull(r, a, b), \
    default: __ckd_mul_default(r, a, b)), \
  default: \
    _Generic ((b), \
    signed long long: __ckd_mul_unimplemented(r, a, b), \
    unsigned long long: __ckd_mul_unimplemented(r, a, b), \
    default: __ckd_mul_default(r, a, b))) \

Removing __ckd_mul_ulongull fixes all the issues, but I don't understand _Generic and ckd_mul to commit the change.

Discussion


Log in to post a comment.