Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias template produces seemingly bogus "template template argument has different template parameters" error #36505

Closed
Quuxplusone opened this issue Apr 17, 2018 · 2 comments · Fixed by #89807
Assignees
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@Quuxplusone
Copy link
Contributor

Bugzilla Link 37157
Version trunk
OS All
CC @DougGregor

Extended Description

I (and also GCC 7.0-and-later) claim that this program is legal C++.

template<template<class> class X> struct A {};
template<template<class...> class Y> using B = A<Y>;
template<class> struct S;
B<S> b;

Clang, on the other hand, bails out at line 2:

prog.cc:2:50: error: template template argument has different template parameters than its corresponding template template parameter
template<template<class...> class Y> using B = A;
^
prog.cc:2:19: note: template type parameter pack does not match template type parameter in template argument
template<template<class...> class Y> using B = A;
^
prog.cc:1:19: note: previous template type parameter declared here
template<template class X> struct A {};
^

Clang becomes happy if I change it from 'using B = A' to 'struct B {}', and then sad again if I change it to 'struct B : A {}'.

@llvmbot
Copy link
Member

llvmbot commented Apr 30, 2018

Looks like -frelaxed-template-template-args enables the fix for this (off by default). See the commit message for r290792 for more info. If we're going to keep this off by default, it would be nice to have better diagnostics for cases like this.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@mizvekov mizvekov self-assigned this Apr 28, 2024
@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Apr 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 28, 2024

@llvm/issue-subscribers-clang-frontend

Author: Arthur O'Dwyer (Quuxplusone)

| | | | --- | --- | | Bugzilla Link | [37157](https://llvm.org/bz37157) | | Version | trunk | | OS | All | | CC | @DougGregor |

Extended Description

I (and also GCC 7.0-and-later) claim that this program is legal C++.

template&lt;template&lt;class&gt; class X&gt; struct A {};
template&lt;template&lt;class...&gt; class Y&gt; using B = A&lt;Y&gt;;
template&lt;class&gt; struct S;
B&lt;S&gt; b;

Clang, on the other hand, bails out at line 2:

prog.cc:2:50: error: template template argument has different template parameters than its corresponding template template parameter
template<template<class...> class Y> using B = A<Y>;
^
prog.cc:2:19: note: template type parameter pack does not match template type parameter in template argument
template<template<class...> class Y> using B = A<Y>;
^
prog.cc:1:19: note: previous template type parameter declared here
template<template<class> class X> struct A {};
^

Clang becomes happy if I change it from 'using B = A<Y>' to 'struct B {}', and then sad again if I change it to 'struct B : A<Y> {}'.

mizvekov added a commit to mizvekov/llvm-project that referenced this issue Apr 28, 2024
…efault

In order to implement this as a DR and avoid breaking reasonable code
that worked before P0522, this patch implements a provisional resolution
for CWG2398: When deducing template template parameters against each other,
and the argument side names a template specialization, instead of just
deducing A, we instead deduce a synthesized template template parameter based
on A, but with it's parameters using the template specialization's arguments
as defaults.

The driver flag is deprecated with a warning.

With this patch, we finally mark C++17 support in clang as complete.

Fixes llvm#36505
mizvekov added a commit to mizvekov/llvm-project that referenced this issue Apr 30, 2024
…efault

In order to implement this as a DR and avoid breaking reasonable code
that worked before P0522, this patch implements a provisional resolution
for CWG2398: When deducing template template parameters against each other,
and the argument side names a template specialization, instead of just
deducing A, we instead deduce a synthesized template template parameter based
on A, but with it's parameters using the template specialization's arguments
as defaults.

The driver flag is deprecated with a warning.

With this patch, we finally mark C++17 support in clang as complete.

Fixes llvm#36505
mizvekov added a commit that referenced this issue May 2, 2024
…efault (#89807)

This patch will finally allow us to mark C++17 support in clang as
complete.
    
In order to implement this as a DR and avoid breaking reasonable code
that worked before P0522, this patch implements a provisional resolution
for CWG2398: When deducing template template parameters against each other,
and the argument side names a template specialization, instead of just
deducing A, we deduce a synthesized template template parameter based
on A, but with it's parameters using the template specialization's arguments
as defaults.
    
The driver flag is deprecated with a warning.
    
Fixes #36505
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants