OiO.lk Blog C# Is it safe to pass a uint32_t to a function which defines the input type as uint64_t?
C#

Is it safe to pass a uint32_t to a function which defines the input type as uint64_t?


Pass a uint32_t to a function that requires uint64_t: You can do this, and all compilers I know accept it, even in strict modes.

  • Is it explicitly allowed by the standard?
  • Is it safe?
  • What does MISRA-C say about this?
void MyFunction(uint64_t arg) {}

int main(void) {
    uint32_t xyz = 1u;
    MyFunction(xyz);
}



You need to sign in to view this answers

Exit mobile version