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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:01:16+00:00 2026-06-03T12:01:16+00:00

For example, GCC and clang both fail to compile the following code: struct S

  • 0

For example, GCC and clang both fail to compile the following code:

struct S {};

namespace N
{
    void g(S);
}

using N::g;

namespace N
{
    void g(int);
}

int main()
{
    g(0);
}

with the error:

test.cpp: In function 'int main()':
test.cpp:17:8: error: could not convert '0' from 'int' to 'S'
     g(0);
        ^

suggesting that the using-declaration only imports the overloads declared above the point where the using-declaration appears, not ones that may appear later (but before the use of the name).

Is this behaviour correct?

  • 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-03T12:01:17+00:00Added an answer on June 3, 2026 at 12:01 pm

    Is this behaviour correct?

    Yes, this behavior is correct and is well defined as per the c++ standard.

    The relevant section is § 7.3.3.11 of C++11 standard:

    The entity declared by a using-declaration shall be known in the context using it according to its definition at the point of the using-declaration. Definitions added to the namespace after the using-declaration are not considered when a use of the name is made.

    [ Example:    
        namespace A {
            void f(int);
         }
        using A::f; // f is a synonym for A::f;
        // that is, for A::f(int).
        namespace A {
            void f(char);
        }
        void foo() {
            f(’a’); // calls f(int),
        } // even though f(char) exists.
        void bar() {
            using A::f; // f is a synonym for A::f;
            // that is, for A::f(int) and A::f(char).
            f(’a’); // calls f(char)
        }
     —end example ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code does not compile with gcc 4.7 (20120114) , but compiles fine
The following example code compiles under gcc and works as I would hope. It
Using gcc 4.4.3 c89: I am just working on the following code below: I
I'm trying to compile the zpipe.c example in my Linux(Ubuntu 8.04) with gcc, but
This example seems to compile with VC10 and gcc (though my version of gcc
When I compile ALSA's pcm_min.c example with gcc -Wall -lasound pcm_min.c -o pcm_min Everything
In GCC, certain warnings require optimization to be enabled. For example: int foo() {
Assume the following toy class, and modern compilers (recent gcc for example). template <typename
When trying to compile the example below, I received a warning: >gcc -o file
vi example.c #include<stdio.h> #include flite.h register_cmu_us_kal(); int main(int argc,char** argv) { cst_voice *v; if(argc!=2)

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.