Repository: shader-slang/slang (2026-04-13T07:27:49Z)

Issue:
Crash / ICE when emitting code for interface types without -conformance flags
## Issue Description

When compiling code that uses `StructuredBuffer<IInterface>` without providing `-conformance` flags to `slangc`, the compiler crashes (SIGSEGV) or hits an internal compiler error (E99999) during code emission. The compiler should instead emit a clean diagnostic such as E50100 ("no type conformances found").

This is a robustness issue: providing `-conformance` flags makes the code compile successfully. The crash only occurs when conformances are omitted.

## Reproducer Code

```hlsl
interface IFoo
{
    float getValue();
}

struct Impl : IFoo
{
    float v;
    float getValue() { return v; }
}

StructuredBuffer<IFoo> inputBuffer;
RWStructuredBuffer<float> outputBuffer;

[numthreads(1, 1, 1)]
void computeMain()
{
    outputBuffer[0] = inputBuffer[0].getValue();
}
```

**Commands (both crash):**
```bash
slangc test.slang -target spirv -entry computeMain -stage compute -emit-spirv-directly
slangc test.slang -target hlsl -entry computeMain -stage compute
```

**With `-conformance`, both succeed:**
```bash
slangc test.slang -target spirv -entry computeMain -stage compute -emit-spirv-directly -conformance "Impl:IFoo=0"
slangc test.slang -target hlsl -entry computeMain -stage compute -conformance "Impl:IFoo=0"
```

## Expected Behavior

The compiler should produce a clean diagnostic (e.g., E50100 "no type conformances found") and exit gracefully.

## Actual Behavior

**SPIRV target** - ICE with unhandled `lookupWitness`:
```
error[E99999]: Slang compilation aborted due to an exception of N5Slang13InternalErrorE unimplemented: Unhandled local inst in spirv-emit:
let  %1 : %2 = lookupWitness(%3, %IFoox5FgetValue)
```

**HLSL target** - ICE with unexpected IR opcode:
```
internal error[E99999]: unimplemented feature in Slang compiler: unexpected IR opcode during code emit
```

A variant with multiple conformances (`[anyValueSize(8)]`, two struct implementations) causes a **segfault** (signal 11) with no diagnostic output on the SPIRV target.

## Affected Tests

The following existing tests in the repo crash when compiled directly with `slangc` without conformances (i.e., outside of `render-test` which provides conformances automatically):

- `tests/language-feature/dynamic-dispatch/structuredbuffer-interface-read.slang` (spirv) - **SIGSEGV**
- `tests/language-feature/interfaces/generic-interface-conformance.slang` (hlsl) - ICE E99999
- `tests/language-feature/interfaces/generic-interface-conformance.slang` (spirv) - ICE E99999
- `tests/language-feature/interfaces/empty-type-conformance.slang` (hlsl) - ICE E99999
- `tests/language-feature/interfaces/empty-type-conformance.slang` (spirv) - ICE E99999

## Environment

- Slang Version: 2026.1.2 (commit 312d479a)
- OS: macOS (ARM64)
- Targets: spirv, hlsl

## Related Issues

- #9445 - Same crash pattern (`lookupWitness` in spirv-emit) but reported as a missing feature rather than a robustness issue
- #10376 - Same ICE pattern with `ByteAddressBuffer.Load<T>` for interface types


Discussion:
**[Agent] Root Cause Investigation**

The crash occurs because `analyzeLoad()` in the typeflow specialization pass (`slang-ir-typeflow-specialize.cpp:2383`) silently returns `none()` when `StructuredBufferLoad` / `RWStructuredBufferLoad` encounters an interface type with no registered conformances. This skips the E50100 diagnostic that the identical code paths for `IRLoad` (line 2317) and `CreateExistentialObject` (line 2066) correctly emit.

Without the error, the pass continues into specialization/translation where unresolved `lookupWitness` and `extractExistential*` instructions trigger the assertion/ICE.

**Fix**: Add E50100 diagnostic emission to the `StructuredBufferLoad` branch in `analyzeLoad()`, matching the existing pattern at the two adjacent code paths. PR incoming.



Patch:
diff --git a/source/slang/slang-ir-typeflow-specialize.cpp b/source/slang/slang-ir-typeflow-specialize.cpp
index e2d3cf84e6b..e17d102c836 100644
--- a/source/slang/slang-ir-typeflow-specialize.cpp
+++ b/source/slang/slang-ir-typeflow-specialize.cpp
@@ -2382,6 +2382,11 @@ struct TypeFlowSpecializationContext
                     }
                     else
                     {
+                        StringBuilder typeStr;
+                        printDiagnosticArg(typeStr, interfaceType);
+                        sink->diagnose(Diagnostics::NoTypeConformancesFoundForInterface{
+                            .interfaceType = typeStr.produceString(),
+                            .location = inst->sourceLoc});
                         module->getContainerPool().free(&tables);
                         return none();
                     }


Test patch:
diff --git a/tests/diagnostics/no-type-conformance-structured-buffer.slang b/tests/diagnostics/no-type-conformance-structured-buffer.slang
new file mode 100644
index 00000000000..75438b1eeba
--- /dev/null
+++ b/tests/diagnostics/no-type-conformance-structured-buffer.slang
@@ -0,0 +1,31 @@
+//DIAGNOSTIC_TEST:SIMPLE(diag=CHECK,non-exhaustive):-target spirv -entry computeMain -stage compute
+//DIAGNOSTIC_TEST:SIMPLE(diag=CHECK,non-exhaustive):-target hlsl -entry computeMain -stage compute
+
+// Test that loading from StructuredBuffer<IInterface> and RWStructuredBuffer<IInterface>
+// without -conformance flags produces a clean E50100 diagnostic instead of crashing (issue #10519).
+
+interface IFoo
+{
+    float getValue();
+}
+
+struct Impl : IFoo
+{
+    float v;
+    float getValue() { return v; }
+}
+
+StructuredBuffer<IFoo> inputBuffer;
+RWStructuredBuffer<IFoo> rwInputBuffer;
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain()
+{
+    outputBuffer[0] = inputBuffer[0].getValue();
+//CHECK:                         ^ no type conformances found
+//CHECK:                         ^ No type conformances are found for interface 'IFoo'. Code generation for current target requires at least one implementation type present in the linkage.
+    outputBuffer[1] = rwInputBuffer[0].getValue();
+//CHECK:                                       ^ no type conformances found
+//CHECK:                                       ^ No type conformances are found for interface 'IFoo'. Code generation for current target requires at least one implementation type present in the linkage.
+}