DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Internal Compiler error: cast<X>() argument of incompatible type with vector type in struct template

Open KStocky opened this issue 1 year ago • 2 comments

Description I am getting an Internal Compiler Error (ICE) with the following code: https://godbolt.org/z/Tde8anb6d

This seems to stem from the combination of using sizeof (which returns an unspeakable HLSL type, unsigned long) on a template argument, trying to provide the template argument to a vector.

The following similar examples will compile just fine:

  1. If I have the exact same vector declaration outside of the template context, things are fine. https://godbolt.org/z/PY7csqT4v
  2. If I use sizeof in the template, and do not depend on the template arg, then things are fine. https://godbolt.org/z/5zYf4bdoo
  3. If I cast the result of the sizeof that produces the ICE to a uint, then it compiles. https://godbolt.org/z/fP1ebzr6d
  4. If the type I am instantiating is not a vector, then it compiles. https://godbolt.org/z/cPfevPxhj

Steps to Reproduce Minimal steps can be found in https://godbolt.org/z/Tde8anb6d

Actual Behavior Full error output: Internal Compiler error: cast<X>() argument of incompatible type! Compiler returned: 29

Environment

  • DXC version 1.7.2308.12
  • Host Operating System Windows 10 Pro Version 22H2

KStocky avatar Jan 31 '24 07:01 KStocky

Solution might involve making the vector template a proper template instead of the hlsl-specific implementation that's there now.

pow2clk avatar Jan 31 '24 16:01 pow2clk

I did wonder if it was related to #4629. It is the same ICE (as in the same error output), however the steps in that issue seemed to be very different to mine, so I made a separate issue to it.

KStocky avatar Jan 31 '24 16:01 KStocky