I went to check the mailing list of the SDCC project. There was a bug for the __critical keyword when it is used with a block. Apparently that was fixed long ago. My issue is when it’s used on a function declaration.

But I also read that the __interrupt doesn’t generate correct code. It is supposed to end with ei, reti. But it leaves off the ei part.

So I’ll do my own critical sections with reference counting and my own prolog and epilog for the interrupt.