It is seems to be an AVR logical conflict. Instruction
SUB Rd,Rr. ; give C=1 when Rd<Rr
COM Rd ; operation like 0xff-Rd , this would give C=0. But actually the complement instruction always give C=1