https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115817
--- Comment #9 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
What can be used as a kind of work-around (and may be even better than the code
with improved Binutils as proposed above), is to hide the value of 0 from the
compiler:
volatile uint8_t var;
__attribute((signal))
void __vector_1 (void)
{
uint8_t zero = 0;
__asm ("" : "+r" (zero));
var = zero;
}
__vector_1:
__gcc_isr 1
ldi r24, 0
sts var, r24
__gcc_isr 2
reti
__gcc_isr 0,r24
00000036 <__vector_1>:
36: 8f 93 push r24
38: 80 e0 ldi r24, 0x00
3a: 80 93 00 00 sts 0x0000, r24 ; 0x800060 <var>
3e: 8f 91 pop r24
40: 18 95 reti