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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:39:33+00:00 2026-05-13T09:39:33+00:00

I noticed a very curious behavior that, if standard, I would be very happy

  • 0

I noticed a very curious behavior that, if standard, I would be very happy to exploit (what I’d like to do with it is fairly complex to explain and irrelevant to the question).

The behavior is:

static void name();
void name() {
    /* This function is now static, even if in the declaration
     * there is no static keyword. Tested on GCC and VS. */
}

What’s curious is that the inverse produces a compile time error:

void name();
static void name() {
    /* Illegal */
}

So, is this standard and can I expect other compilers to behave the same way? Thanks!

  • 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-05-13T09:39:34+00:00Added an answer on May 13, 2026 at 9:39 am

    C++ standard:

    7.1.1/6: “A name declared in a namespace scope without a
    storage-class-specifier has external
    linkage unless it has internal linkage
    because of a previous declaration” [or unless it’s const].

    In your first case, name is declared in a namespace scope (specifically, the global namespace). The first declaration therefore alters the linkage of the second declaration.

    The inverse is banned because:

    7.1.1/7: “The linkages implied by successive declarations for a given
    entity shall agree”.

    So, in your second example, the first declaration has external linkage (by 7.1.1/6), and the second has internal linkage (explicitly), and these do not agree.

    You also ask about C, and I imagine it’s the same sort of thing. But I have the C++ book right here, whereas you’re as capable of looking in a draft C standard online as I am 😉

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

Sidebar

Related Questions

i noticed that paypal displays a very different favicon, one that's not just a
i've noticed that plenty of games / applications (very common on mobile builds) pack
I noticed that JavaScript's new Date() function is very smart in accepting dates in
I have switched on the Codeigniter profile (very useful) and I have noticed that
I've noticed a site that seems to have a very nice colour transition effect
I have noticed that on the iPad the google maps app has a very
I've noticed that there is a very dramatic difference in the user experience for
I came upon a strange behavior that has left me curious and without a
I noticed that the WPF designer does a very poor job on aligning the
I've noticed that some email services (like gmail or my school's webmail) will redirect

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.