Is there a conflict between stencil test and RTT?

I need to render the scene with the stencil applied to texture, but the result of RTT is incorrect. Directly rendering it to screen is correct, I don’t know why. The question is when RTT, the part that didn’t pass stencil test will be rendered to texture too.
The case is from official demo clipping stencil


this is render to screen

this is render to texture ,then using shader reading texture, render to screen. we can it’s a result without stencil test.