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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:34:25+00:00 2026-06-02T17:34:25+00:00

The assertion in the following program gives different results according to the compiler used:

  • 0

The assertion in the following program gives different results according to the compiler used: in GCC 4.4 the assertions fails, while in CLang does not. It looks like GCC does not like V being private in C. Is this a bug?

#include <cassert>

class V {
public:
    virtual ~V() { };
};

template<class T>
class C : public T, private V {
public:
    static V* new_() {
        return new C();
    }
};

struct MyT {
};

typedef C<MyT> C_MyT;

int main(int argc, char** argv) {
    V* o2 = C_MyT::new_();
    assert(dynamic_cast<C_MyT*> (o2)); // failure in GCC, success in CLang
    return 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-02T17:34:26+00:00Added an answer on June 2, 2026 at 5:34 pm

    g++ appears to be behaving correctly. See Dynamic downcast on private inheritance within private scope which has a good answer describing this.

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

Sidebar

Related Questions

When running valgrind on the following program the assertion fails: #include <unistd.h> #include <sys/mman.h>
The following assertion fails in RAD Studio 2010 (and incidentally would succeed in Visual
I wonder how to debug the following error: Debug Assertion failure Program: tomtoprog.exe File:
I am getting the following error when running my program. Debug Assertion Failed! File:
The following code snippet gives the error message at run time of: Debug assertion
Why does this assertion fail? Assert.AreEqual( Color.Red, Color.FromArgb( Color.Red.A, Color.Red.R, Color.Red.G, Color.Red.B ) );
When my Cocoa app hits an assertion in the code, gdb gives me a
Is the following program a valid C program? #include <stdio.h> int main() { fwrite(x,
Consider the following C# program: using System; using System.Diagnostics; namespace Test { class MainClass
How do I get the following assertion to succeed? { int i = 5;

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.