For example, say I have the following code:
#include <stdint.h>
#define MAX_SIZE 0x10000000
#define min(a,b) (((a) < (b)) ? (a) : (b))
extern uint64_t external_uint64_t;
...
uint64_t wide = min(external_uint64_t, MAX_SIZE);
uint32_t narrow = (uint32_t) wide;
Is this well defined and guaranteed to initialize narrow with the smallest of the values between external_uint64_t, and MAX_SIZE?
For unsigned numbers it is well defined by the C standard, but if the result of
minwill not fit into the unsigned integer type it will be converted the way described in the C standard.