The assertion fails when the expression causing the this pointer to be captured is part of a constexpr if statement's branch and the branch gets discarded when the enclosing method is instantiated.
Note that the test case is added to CodeGen instead of Sema since the translation unit has to be free of errors in order for the assertion to be checked.