Arduino Due - Strange variable behavior

I am getting a strange assignment of two integer variables using #define statements

#define DAY 1
#define NIGHT 2
#define ON 1
#define OFF 0
int SunStatus = 0;
int PrevSunStatus = 0;

loop() {
char tempbuf[80];

if(digitalRead(24) == ON) SunStatus = DAY;
else SunStatus = NIGHT;

if(SunStatus != PrevSunStatus) {
sprintf(tempbuf, "SunStatus %d, PrevSunStatus %d", Suntatus, PrevSunStatus);
Serial.println(tembuf);
//other code to do things here
PrevSunStatus = SunStatus;
}

The output is that SunStatus is 1 and PrevSunstatus = 65538

Then subsequent output PrevSunStatus = 65537

Why?

Please post the whole of your actual code, using code tags when you do.

Suntatus

, shouldn't that be SunStatus?

Yes, it is. Note that was just a typo when I hand typed the code over as I was trying to get the essence of the problem. The actual code is far far too large to post here.

If you enter the code segment I show above, unfortunately it DOES NOT recreate the problem as it works (correcting typos of course).

What is odd is if I change the type in my full code for SunStatus and PrevSunStatus to byte it 'works'. If I go back to int the problem comes back.

The actual code is far far too large to post here.

Why ?

If you cannot post all of your code or a smaller but complete program that illustrates the error then it is going to be difficult to provide any help.