------- Comment #4 from hutchinsonandy at aim dot com 2008-06-11 22:05 ------- I'm sure Eric will weight in again to verify code posted executes correctly (it looks correct to me).
I suspect you have some config or memory issue. For example, unoptimized, the string is stored at location 0x100 and 0x101. So if this get trashed, (by another part of software) the result will be 2. Also watch your stack space. Unoptimized, it will be large and overflow data areas The optimization, of course will bypass such problems -and that works. This also shows that front end and middle of gcc are ok. The code contains no tricky or seldom used instructions - so it appears highly unlikely to be a problem with back end which is specfic to avr. If Eric confirms this he may mark bug as invalid - but you can pursue a solution on other forums (such as http://lists.nongnu.org/mailman/listinfo/avr-gcc-list) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36494