microsoft / microsoft/DirectXShaderCompiler

SIGSEGV on template override mismatch

Open
#7,154 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug crash incorrect-code
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description
I am encountering a SIGSEGV when setting a type template parameter with a default value: By passing it in a function with overriden template parameters as inout, it produces a crash.

Steps to Reproduce
Here is a small repro sample code

template <typename T, typename A = uint> // 1. Here we set default template parameter value
struct TemplatedType {
    T value;
};
template<typename T>
void increment(inout TemplatedType<T, float> value) { // 2. Here we require a second parameter different from the default one. The inout is important there
  value.value += 1.0;
}
void main() {
  TemplatedType<float> oui; // 3. Here we define with second template parameter as default
  increment<float>(oui); // 4. Here we should have an error, but instead we have a SIGSEGV
}

Here is a link on godbolt

Actual Behavior
This should not crash and simply return an error, such as C++ with visual studio.

Environment

  • DXC version 1.8.2407
  • Host Operating System Windows 11 & Godbolt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the supplied HLSL repro with DXC and confirm the SIGSEGV on the template argument mismatch in the inout call. Trace template parameter checking for this call and verify that the compiler reports an error instead of crashing; no source files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.