Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7920961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:24:24+00:00 2026-06-03T16:24:24+00:00

is this a gcc bug or somehow wrong usage of parameter packs? (Compiled with

  • 0

is this a gcc bug or somehow wrong usage of parameter packs?

(Compiled with gcc 4.6.3 🙂

#include <iostream>
template<class...Ts> struct tuple{};
template<class...>class test;

template< template <class...> class tp,
  class...arg1Ts,
  class...arg2Ts> 
class test<tp<arg1Ts...>,tp<arg2Ts...>>{
  public:
  void test1(arg1Ts... arg1s,arg2Ts... arg2s){
  std::cout<<sizeof...(arg1s);  //Why is this 2? Why not 0?
  std::cout<<sizeof...(arg2s);  //2 ok
 }
};
int main(){
 test<tuple<>,tuple<char,int>> t1; //(arg1Ts... = empty), (arg2Ts... = char,int)
 t1.test1('a',2); //prints 22, not 02
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:24:28+00:00Added an answer on June 3, 2026 at 4:24 pm

    I put here a compilable example:

    #include <iostream>
    
    template <class...> class test;
    
    template <
        template <class...> class tp,
        class...arg1Ts,
        class...arg2Ts
    > 
    class test < tp<arg1Ts...>, tp<arg2Ts...> > {
    public:
        void test1(arg1Ts..., arg2Ts...) {
            std::cout << sizeof...(arg1Ts) << ' ' << sizeof...(arg2Ts) << '\n';
        }
    };
    
    template <typename...> class Pack;
    
    int main(){
       test< Pack<>, Pack<char,int>> t1;
       t1.test1('a', 2);
    }
    

    (not much different from yours, but it compiles cleanly)

    Using clang 3.0, this gives:

    0 2
    

    which is exactly what is expected. So I would figure a bug with the version of gcc you are using. Time to move on to 4.7 ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I compiled this (gcc compiler): #include <stdio.h> main() { struct { a:1; b:2; }
I compiled this (gcc compiler) : #include< stdio.h> main() { unsigned char ch; FILE
MWE #include <iostream> struct Foo { Foo() { std::cout << Constructing Foo << this
I have compiled my application on Linux (Intel) machine using this command gcc –g
okay, i'm curious why gcc calls this an ambiguity. check this: class base_stream {
This code compiles fine with GCC and Clang but not with MSVC 2010: #include
This is an academic question. In the report for GCC bug 38764 , there
Look at this template: template <class T> auto checkErrorCode(T& functor) -> decltype(functor()) { auto
Consider the following code: #include <algorithm> #include <iostream> #include <vector> struct A { int
This code: #include <iostream> #include <cstdio> #include <fstream> #include <string> int main() { std::remove(test.txt);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.