DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
Template error (non-type template argument of type '<dependent type>' must have an integral or enumeration type) with a particular use of the ternary/conditional operator in a template instantiation
Description This code fails to compile https://godbolt.org/z/G98xG5xja. It would appear that if we are using a ternary operator to evaluate a template argument, AND the conditional part of that ternary operator uses a template instantiation, THEN that template instantiation must appear in one of the two following expressions.
To demonstrate that this is possibly the issue, here are some succeeding and failing cases:
- No template instantiations are involved. This succeeds: https://godbolt.org/z/bx5Y8qqaM
- One of the return expressions of the ternary operator is also a template but is different from the one used in the condition expression. This fails: https://godbolt.org/z/bWTbn7n7v
- The condition and one of the return expressions contain the same template instantiation. This succeeds: https://godbolt.org/z/xExchWbjd
- One of the return expressions has the same template instantiation but in a more complex way. This succeeds (and is my workaround): https://godbolt.org/z/46TsEzvqd
Steps to Reproduce https://godbolt.org/z/G98xG5xja https://godbolt.org/z/bWTbn7n7v
Steps to Workaround https://godbolt.org/z/bYeKsWv7Y
Actual Behavior
We get "non-type template argument of type '
Environment
- DXC version 1.7.2308.12
- Host Operating System Windows 10 Pro 22H2