From: SourceForge.net <no...@so...> - 2010-09-23 19:28:03
|
Bugs item #1512044, was opened at 2006-06-25 10:50 Message generated for change (Comment added) made by spth You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1512044&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: pic16 target Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Borut Ražem (borutr) Assigned to: Nobody/Anonymous (nobody) >Summary: pic16: bad code for unitialized unsigned char Initial Comment: unsigned char ttt[] = {0xff, 1}; unsigned char test(void) { unsigned char a, i; // a = 0; /* uncomment this line to generate correct code */ for (i = 0; i < sizeof(ttt); i++) { a |= ttt[i]; } return a; } The return value is 1, but is should be 0xff. If the variable a is initialized, the result is correct. This is a minimized code from the regression test bug-971834.c. $sdcc --version SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.5.6 #4244 (Jun 24 2006) (MINGW32) sdcc -mpic16 -pp18f452 t.c Borut ---------------------------------------------------------------------- >Comment By: Philipp Klaus Krause (spth) Date: 2010-09-23 21:28 Message: Not really helpful for fixing this, but maybe interesting to the readers: unsigned char is the only type for which such a bug can exist. If the variable a was of any type other than unsigned char, the |= on the uninitialized value would be undefined behaviour. For unsigned char though, it's unspecified behaviour instead. Philipp ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1512044&group_id=599 |