> Thanks to the suggestion I received, I finally fixed the problem. > > timediff_t Curl_timediff(struct curltime newer, struct curltime older) > { > - timediff_t diff = newer.tv_sec-older.tv_sec; > + timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec > > This code apsolutely worked well, no endless loop any more. > > The cast has higher precedence than the addition, so this would end up > signed subtracting unsigned resulting unsigned, I think. > Is my understanding wrong?
I'm afraid it's wrong. Your modified version is correct, though missing the semicolon (;). Your first version does this: timediff_t diff = ( (timediff_t)newer.tv_sec ) - older.tv_sec; See operator precedence here: https://en.cppreference.com/w/c/language/operator_precedence ------------------------------------------------------------------- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html