I am working on a large piece of code for a 18F2550. I have had it several times that the watchdog went off.
I was able to trace the problem to an endless loop in _modulong. I think this is the code in lib/pic16/libsdcc/long/modulong.c. The code for the pic14 target has an extra line with comments ("/* prevent endless loop (division by zero exception?!?) */") which the pic16 code does not have. Could this be the problem?
I "fixed" _modulong(a, b) to return ~0UL for b==0 instead of entering an infinite loop in r8388.
However, if your program triggered this division-by-0 several times already, you may have to look into your code again: Division-by-0 triggers undefined behaviour as per the C standard (see, e.g., Clause 6.5.5.5 in draft N1548), so that an endless loop is a perfectly valid implementation.
Raphael
I did some more debugging, and the original function call is a printf, but I don't know exactly with which parameters.
If _modulong may not be called with b==0, there may be a problem somewhere between printf and _modulong.
The problem is that I have a hard time reproducing this. My code prints the temperature every half second to the serial port, but the endless loop seems to happen at random. Sometimes it takes 9 hours, sometimes 1 hour.
printf("Temp: %d\n\r", temperature);
I'd say that entering an infinite loop and optionally let a watchdog bite is preferable over just returning 0.