[clang] [Clang] Tolerate constant evaluation failure when transforming SubstNonTypeTemplateParmExpr in unevaluated contexts (PR #196791)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Sun May 10 19:13:42 PDT 2026


zyn0217 wrote:

> So this expression has been transformed twice, first when checking the template arguments for the concept/template specialization, and then in the second time for the SubstNonTypeTemplateParmExpr transform.
> 
> Why does it fail the second time but not the first? Supposedly the first time around it was also an Unevaluated context. Have we messed up the contexts somehow?

AFAIK the first transform happens in the parameter building where all of the template arguments are dependent. Therefore it doesn't fail.

The underlying issue is that, whether we want to allow users to instantiate templates from a decltype expression; technically we shouldn't but before our normalization patch it was accidently allowed (we instantiated the constexpr functions before substituting into decltypes whereas we normalize decltype first and then substitute now) and mpunits seems to rely on that behavior.

https://github.com/llvm/llvm-project/pull/196791


More information about the cfe-commits mailing list