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

Rejects-valid with variadic alias template in variadic class template #17042

Open
efriedma-quic opened this issue Jul 20, 2013 · 5 comments
Open
Labels
bugzilla Issues migrated from bugzilla c++11 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party

Comments

@efriedma-quic
Copy link
Collaborator

Bugzilla Link 16668
Version unspecified
OS All
Attachments Patch for discussion
CC @DougGregor,@zygoloid

Extended Description

Testcase:

template<int ...Args1> struct A {
template<int ...Args2> using B = A<(Args1+Args2)...>;
};
template<int ...Args> using X = A<1,2,3>::B<Args...>;

Currently prints:
:2:53: error: pack expansion contains parameter pack 'Args2' that has a different length (3 vs. 1) from outer parameter packs
template<int ...Args2> using B = A<(Args1+Args2)...>;
~~~~~ ^
:4:43: note: in instantiation of template type alias 'B' requested here
template<int ...Args> using X = A<1,2,3>::B<Args...>;
^
1 error generated.

I don't see any obvious reason why this wouldn't be allowed by the standard.

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Jul 21, 2013

My current line of thinking is that clang is expanding the parameter pack
too early; attached patch delays the expansion. Not a complete patch, but
this illustrates what I'm thinking.

I came up with an essentially identical approach. The test added for #17020 seems to fail with such a patch, due to an assertion failure in template argument deduction. Extended test case triggering the same assertion failure:

--- test/SemaCXX/alias-template.cpp (revision 186726)
+++ test/SemaCXX/alias-template.cpp (working copy)
@@ -170,3 +170,34 @@
fail1 f1; // expected-note {{here}}
fail2 f2; // expected-note {{here}}
}
+
+namespace #17042 {

  • template<int, typename> struct P {};
  • template<int ...A> struct S {
  • template<int ...B> using sum = S<A + B ...>; // expected-error {{different length (3 vs. 4)}}
  • template<typename ...Ts> void f(P<A, Ts> ...);
  • template<typename ...Ts> using Fn = void(S::*)(P<A, Ts>...);
  • template<typename ...Ts> void g(Fn<Ts...>);
  • };
  • template<int ...C> using X = S<1, 2, 3>::sum<4, C ...>; // expected-note {{here}}
  • using Y = X<5, 6>;
  • using Y = S<5, 7, 9>;
  • using Z = X<5, 6, 7>; // expected-note {{here}}
  • void g() {
  • P<0, int> p0;
  • P<1, char> p1;
  • P<2, double> p2;
  • using S = S<0, 1, 2>;
  • S s;
  • s.f(p0, p1, p2);
  • s.g(&S::f<int, char, double>);
  • s.g<int, char, double>(&S::f);
  • }
    +}

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
@xgupta xgupta added the clang Clang issues not falling into any other category label Jan 29, 2023
@Endilll Endilll added clang:frontend Language frontend issues, e.g. anything involving "Sema" compile-fail Use [accepts-invalid] and [rejects-valid] instead and removed clang Clang issues not falling into any other category labels Jun 25, 2023
@llvmbot
Copy link
Member

llvmbot commented Jun 25, 2023

@llvm/issue-subscribers-clang-frontend

@Endilll
Copy link
Contributor

Endilll commented Jun 25, 2023

Nothing has changed as of Clang 16: https://godbolt.org/z/86YzhKjb6

@Endilll Endilll added confirmed Verified by a second party and removed compile-fail Use [accepts-invalid] and [rejects-valid] instead labels Aug 7, 2023
@vient
Copy link
Member

vient commented Oct 6, 2023

Since #61415 seems to be caused by this issue, I'll note that this is affecting c++23 builds with libstdc++-13.

Example

docker run -it --rm ubuntu:mantic bash -c "
export DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC
apt update
apt install -y gcc-13 clang-17
echo '
  #include <map>
  #include <tuple>
  void f() {
    std::map<std::tuple<int, int>, int>{}[std::make_tuple(0, 0)];
  }
' > test.cpp
clang++-17 -std=c++23 test.cpp"

https://godbolt.org/z/obGY1a8rr

@vient
Copy link
Member

vient commented Dec 19, 2023

My previous example seems to be fixed in trunk: https://godbolt.org/z/eMfYsEbo1
But the original one here is not: https://godbolt.org/z/TPdhK7rGv

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++11 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party
Projects
None yet
Development

No branches or pull requests

5 participants