llvm / llvm/llvm-project

clang triggers an "UNREACHABLE executed" assertion (somehow related to typename)

Open
#169,189 4 comments 0 reactions 0 assignees View on GitHub
clang:codegen confirmed crash regression:18
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This test program shows the assertion on Godbolt: https://godbolt.org/z/Md3vhYx1j

```cpp
#include

template
class Presets final
{
public:
using PresetMapping=T;
};

class Class
{
public:
template
void updatePresets(Presets::PresetMapping& p_presets);
template
Presets::PresetMapping::value_type getVisiblePreset();
};

template
void Class::updatePresets(Presets::PresetMapping& /*p_presets*/)
{
[[maybe_unused]] const typename Presets::PresetMapping::value_type visiblePreset = getVisiblePreset();
}

template
Presets::PresetMapping::value_type Class::getVisiblePreset()
{
return {};
}

int main()
{
Presets::PresetMapping presetMapping;
Class().updatePresets(presetMapping);
return 0;
}

```

Interestingly, the assertion vanishes if two "typename" keywords are added in lines 16 and 26: https://godbolt.org/z/Kza9z5eYn

This was actually how I found the issue. clang-tidy check readability-redundant-typename reported the two "typename" keywords to be unnecessary. However after their removal the assertion occurred.

MSVC 17.14 (VS 2022) compiles the code with and without the "typename" keyword.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.