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

wrong variadic template expansion #323

Closed
dvirtz opened this issue Jun 20, 2020 · 1 comment
Closed

wrong variadic template expansion #323

dvirtz opened this issue Jun 20, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@dvirtz
Copy link

dvirtz commented Jun 20, 2020

in an expansion of

template<typename... Args> struct count;

template<>
struct count<> {
  static const int value = 0;
};

template<typename T, typename... Args>
struct count<T, Args...>
{
  static const int value = 1 + count<Args...>::value;
};

static_assert(count<int, double>::value == 2, 
              "2 elements");

the last expansion uses value instead of count<>::value:

/* First instantiated from: insights.cpp:11 */
#ifdef INSIGHTS_USE_TEMPLATE
template<>
struct count<double>
{
  static const int value = 1 + value;
};

#endif

https://cppinsights.io/s/2701bf6e

@andreasfertig
Copy link
Owner

Hello @dvirtz,

thank you for spotting and reporting this! I will have a look at it. I suspect it is a bit harder to fix. Managing the namespaces wasn't easy in the past.

Andreas

@andreasfertig andreasfertig added the bug Something isn't working label Jun 22, 2020
andreasfertig added a commit that referenced this issue Jul 24, 2020
Fixed #323: Missing final specialization is now there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants