DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Integer vector as enum type causes ICE rather than error

Open Ipotrick opened this issue 3 years ago • 3 comments

Hi, I am using the DXC c++ interface to compile hlsl to spirv. I found an internal compiler crash inside the "Compile" function of DxcCompiler3. I am using the msvc clang toolchain version 13.0.0 to compile. I downloaded the latest version of dxc from the repository (dbd8db0e84420e063f6f7da974a32d58aa79b64b). I can compile other code just fine and i also get error messages for other mistakes in my hlsl. Here are my used arguments: -Zpc -spirv -fspv-target-env=vulkan1.1 _o3 -E -T cs_6_0 -HV 2021. Minimal example that causes the compiler crash (reading illegal memory address, address varies from run to run):

enum EE : uint3 {
    E = uint3(0,0,0),
};

I am new to dxc and hlsl and i dont even know if it is legal to use a uint3 as a "Supper" for an enum, but i am sure it should NOT crash when i give a missinput like that.

Ipotrick avatar Apr 09 '22 01:04 Ipotrick

Thanks for the report @ipotrick! Welcome to DXC!

Using an integer vector as the type for an enum is not allowed. We should produce an error here just as we do if you try to use float.

Just a note for @jaebaek and @sudonatalie that this issue is not limited to SPIRV.

pow2clk avatar Apr 20 '22 18:04 pow2clk

@pow2clk Thank you for letting us know :)

jaebaek avatar Apr 21 '22 19:04 jaebaek

Some added context here. This crashes for DXIL and SPIR-V.

Enum type specifier must be an integral basic type. It cannot be a vector, floating-point type, struct or array.

llvm-beanz avatar Jul 31 '23 21:07 llvm-beanz