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

  • Home
  • SEARCH
  • 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 9006587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:27:05+00:00 2026-06-16T01:27:05+00:00

This code does not compile with GCC4.7 struct A {}; void f(A); struct B

  • 0

This code does not compile with GCC4.7

struct A {};
void f(A);

struct B { B(std::tuple<A>); };
void f(B);

int main() {
  f(std::make_tuple(A()));
}

Because GCC derives from A to make use of the empty base class optimization. However that causes GCC to pick f(A) and complain

error: 'A' is an inaccessible base of 'tuple<A>'

Is this error granted by the C++ Standard or is this simply a bug of libstdc++?

  • 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-16T01:27:06+00:00Added an answer on June 16, 2026 at 1:27 am

    Under clause 17 Library introduction:

    17.5.2.3 Private members [objects.within.classes]

    1 – Clauses 18 through 30 and Annex D do not specify the representation of classes, and intentionally omit specification of class members. An implementation may define static or non-static class members, or both, as needed to implement the semantics of the member functions specified in Clauses 18 through 30 and Annex D.

    This is supported by 1.4 Implementation compliance [intro.compliance]:

    3 – For classes and class templates, the library Clauses specify partial definitions. Private members (Clause 11) are not specified, but each implementation shall supply them to complete the definitions according to the description in the library Clauses.

    Implementing specified semantics through inheritance is not explicitly discussed anywhere in clause 17, but it is implicitly permitted through paragraph 3 of 17.5.2.3 above:

    3 – An implementation may use any technique that provides equivalent external behavior.

    This is how, for example, the node-based ordered associative containers can share implementation detail (including, eventually, class members) through inheritance.

    Since the external behaviour of tuple is changed between having A as a class member and directly inheriting it, and since this change of behaviour causes the rejection of otherwise well-formed programs (as opposed to just changing the sizeof of a class), libstdc++ is in violation of the Standard.

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

Sidebar

Related Questions

This code does not compile: class C {}; void foo (C& c) {} C
This code does not compile, using Boost 1.48 and GCC: // const char* left,
This code does not compile in GHC 7.0.3: import System.IO main = do z
Why does this code not compile? (gcc 4.7.0) // Class with a simple getter/setter
Why this code does not compile (Cygwin)? #include <vector> template <class Ttile> class Tilemap
I just found my code like this does not compile right? Is there any
The following code compiles in MSVC++, but does not compile in GCC 4.5.1: #include
I cannot understand why this piece of code does not compile: namespace A {
Consider this code: #include <iostream> void f(int&& i) { std::cout << f(int&&)\n; } void
The following code does not compile with gcc 4.7 (20120114) , but compiles fine

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.