llvm / llvm/llvm-project

[clang] class template deduction guides is not accepting type alias to to the template itself

Open
#189,939 12 comments 0 reactions 0 assignees View on GitHub
c++17 clang:frontend diverges-from:gcc diverges-from:msvc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

clang is only C++ compiler not accepting following code:

```c++
template struct tmpl_type;

using Integer = tmpl_type;

template struct tmpl_type { };

tmpl_type(int) -> Integer;
```
https://compiler-explorer.com/z/PsdGefz5h

It gives confusing error message:
> deduced type 'Integer' (aka 'tmpl_type') of deduction guide is not a specialization of template 'tmpl_type'

I know that the standard mandates simple-template-id there [temp.deduct.guide#1](https://eel.is/c++draft/temp.deduct.guide#1), but I think it should be an extension to allow alias leading to same template for which the CTAD is. Especially because clang has attribute `[[clang::preferred_name(NAME)]]`.

Contributor guide

Open the contributing guide

Research direction

Start by compiling the minimal C++ reproducer from the issue and compare the behavior with [temp.deduct.guide#1]. Read the discussion about allowing an alias to the same template, including the relationship to clang::preferred_name; done means the intended behavior and diagnostic are agreed and covered by compiler tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.