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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:30:32+00:00 2026-06-01T14:30:32+00:00

I was going to file a bug against GCC, but then realized that if

  • 0

I was going to file a bug against GCC, but then realized that if my interpretation of the Standard is correct, it’s a core language defect, not a compiler bug.

When a static data member of array type is defined outside class scope, identifiers in the array bound are looked up in class scope.

§9.4.2 [class.static.data] says “The initializer expression in the definition of a static data member is in the scope of its class (3.3.7),” but doesn’t say anything about the declarator itself. It seems that this is the only name lookup context within a declarator.

§8.4.2 [dcl.array] doesn’t mention the scope of the array bound, so by default the expression is evaluated in the enclosing scope, which is the namespace.

class X {
  static int const size = some_complicated_metafunction<>::value;
  static int arr[ size ];
};

// "size" should be qualified as "X::size", which is an access violation.
int X::arr[ size ] = {};

The problem is that if the array bound is not evaluated in class scope, there is no way to access private class members, and some_complicated_metafunction<> would have to be respecified. The array bound needs the same scope as the initializer, for essentially the same reason as the initializer. (Although not quite as strong, since constant expressions can always be recomputed, unlike the address of a private object.)

Am I missing something or is a DR in order?

  • 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-01T14:30:34+00:00Added an answer on June 1, 2026 at 2:30 pm

    I think the array bound in a member definition is in class scope. Standard 3.3.7/1:

    The following rules describe the scope of names declared in classes.

    …

    5) The potential scope of a declaration that extends to or past the end of a class definition also extends to the regions defined by its member definitions, even if the members are defined lexically outside the class (this includes static data member definitions, nested class definitions, member function definitions (including the member function body and any portion of the declarator part of such definitions which follows the declarator-id, including a parameter-declaration-clause and any default arguments (8.3.6). …

    Here the declarator-id is X::arr.

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

Sidebar

Related Questions

I am going to file this as a bug report, but I wanted to
I'm going through the Wikitravel API and I noticed that the XML file that
I am trying to get logging via the application.ini file going and I am
I want to convert vb this code <?php // Where the file is going
While going through the syslog file, I found a message like shutdown via gdm
I am going to convert some file using php and send it as a
When I am going to upload a file, my $_POST variable knows the file
I'm going to pass through some values between two required/included php file,ex: mysql.php: <?php
So I have a simple setup going here where I load up a file
Everything was going great until I added AddHandler application/x-httpd-php5s .php to the .htaccess file

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.