Skip to content

ICE when accessing static const interface member through dynamic dispatch #10150

@jvepsalainen-nv

Description

@jvepsalainen-nv

Description

Accessing a static const member of an interface through dynamic dispatch causes an internal compiler error (ICE 99999) instead of producing a proper diagnostic or generating correct code.

Reproducer

interface ILabeled
{
    static const int label;
}

struct LinOp : ILabeled
{
    static const int label = 10;
}

struct QuadOp : ILabeled
{
    static const int label = 20;
}

int getLabel(ILabeled op)
{
    return op.label;
}

Compile with:

slangc repro.slang -target hlsl -stage compute -entry computeMain

The same ICE also occurs when accessing via a generic parameter with dynamic dispatch:

int getLabel<T : ILabeled>(T op)
{
    return T.label;
}

Expected behavior

The compiler should either:

  • Generate correct dynamic dispatch code for static const members (similar to how static methods are dispatched), or
  • Produce a clear diagnostic explaining that static const members cannot be used with dynamic dispatch

Actual behavior

error 99999: unexpected IR opcode during code emit

Affects both HLSL and SPIRV targets.

Notes

  • static methods on interfaces dispatch correctly through dynamic dispatch - only static const members are affected
  • static const in interfaces works correctly when the concrete type is known at compile time (see tests/language-feature/constants/static-const-in-interface.slang)
  • A disabled diagnostic test documenting this ICE was added in Add tests for static method dispatch on interface-typed values #10149

Metadata

Metadata

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions