Fix vector type scalar checking when the scalar operand is dependent
As reported in PR45298 and PR45299, vector_size type checking would crash when done in a situation where the scalar is dependent, such as a member of the current instantiation. This is because the scalar checking ensures that you can implicitly convert a value to a vector-type as long as it doesn't require truncation. It does this by using the constant evaluator to get the value as a float. Unfortunately, if the scalar is dependent (such as a member of the current instantiation), we would hit the assert in the evaluator. This patch suppresses the truncation- of-value check in the first phase of translation. All values are properly errored upon instantiation. This has one minor regression, in that previously in a non-asserts build, template<typename T> struct S { float4 f(float4 f) { return k + f; } static constexpr k = 1.1; // causes a truncation on conversion. }; would error immediately. Because 'k' is value dependent (as a member-of-the-current-instantiation), this would still be evaluatable (despite normally asserting). Due to this patch, this diagnostic is delayed until instantiation time.
Loading
Please sign in to comment