This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bug in compiler.

I use evalution version 3.36 of keil compiler. Consider compilable code:

#include <REG52.H>

typedef unsigned char BYTE;

BYTE BufStart = 0;
BYTE BufStop = 0;
BYTE IP_ADDR[1];

void send_byte(char c) {
	while (!TI);
	TI = 0;
	SBUF = c;
}

void main () {

   // initialization of serial data rate
    SCON  = 0x50;
    TMOD |= 0x20;
    TH1   = 243;
    TR1   = 1;
	TI = 1;

	// send addresses of variables to serial

	send_byte(&BufStop);    // 10
	send_byte(&BufStart);   // 9
	send_byte(IP_ADDR);     // 8
	send_byte(&IP_ADDR[0]); // 8
	send_byte(&IP_ADDR[1]); // 9

	for (;;);

}
As you see that starting address of array is 8. The address of BufStart variable is 9. In other words IP_ADDR[1] and BufStop share the same address. Therefore, I'm not surprised that writing a value into IP_ADDR[1] causes BufStop variable to change accordingly.
It is a bug, because it it is not documented.