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 9139321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:22:20+00:00 2026-06-17T09:22:20+00:00

For the following code #include <array> template<unsigned MaxP, typename type> struct kernel { static

  • 0

For the following code

#include <array>

template<unsigned MaxP, typename type>
struct kernel
{
  static constexpr unsigned max_pole(unsigned P)
  { return P>MaxP? MaxP:P; }

  template<unsigned P>
  using array = std::array<type,max_pole(P)>;          // wrong?

  template<unsigned P>
  static void do_something(array<P> const&, array<P>&);
};

gcc 4.7.0 (g++ -c -std=c++11) gives

error: ‘max_pole’ was not declared in this scope

Is this correct (behaviour of the compiler)? Note that if I resolve max_pole by replacing it with kernel::max_pole on the line indicated, it compiles fine.

EDIT Reported to bugzilla, accepted as bug c++/55992, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55992. Also occurs with gcc 4.7.x and 4.8.0.

  • 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-17T09:22:21+00:00Added an answer on June 17, 2026 at 9:22 am

    Your template compiles fine with Clang 3.2. I strongly believe it is a GCC bug (which is present in GCC 4.7.2 as well, btw). Change notes for GCC 4.8.0 do not seem to mention any such bugfix.

    Also notice, that the compilation error disappears if you remove the declaration of do_something<>, which should not make any difference.

    One more hint: while this template does not compile on GCC 4.7.2:

    template<unsigned MaxP, typename type>
    struct kernel
    {
        static constexpr unsigned max_pole(unsigned P)
        { return P>MaxP? MaxP:P; }
    
         template<typename T>
         using array2 = int[max_pole(3)]; // ERROR!
    
         static void do_something(array2<int> const&, array2<int>&);
    };
    

    This template does compile:

    template<unsigned MaxP, typename type>
    struct kernel
    {
        static constexpr unsigned max_pole(unsigned P)
        { return P>MaxP? MaxP:P; }
    
         // template<typename T>  <--- removed
         using array2 = int[max_pole(3)]; // OK
    
         static void do_something(array2 const&, array2&);
    };
    

    Since max_pole is in both cases an unqualified independent name, the lookup strategy should be the same in both cases, and it is not. To me, this qualifies it as a bug.

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

Sidebar

Related Questions

The following code looks fine to me: #include <stdio.h> template <typename T> struct A
Please consider the following code: #include <iostream> #include <typeinfo> template< typename Type > void
I have this code #include <vector> #include <array> template <typename T> struct Vertice {
The following code #include <stdio.h> template <typename T, T v> class Tem { T
In the following code: #include <iostream> template <typename T, size_t N> void cal_size(T (&a)[N])
The following code: #include <iostream> #include <array> using namespace std; constexpr int N =
I've a question regarding the following code: #include all_needed.h static uint8_t array[2] = {0};
Is it worth to write code like the following to copy array elements: #include
Consider the following code when a new container is defined over a std::array #include
With the following code, if I attempt to convert a template array to std::string,

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.