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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:59:11+00:00 2026-05-13T13:59:11+00:00

Is there any way to view the default functions ( e.g., default copy constructor,

  • 0

Is there any way to view the default functions ( e.g., default copy constructor, default assignment operator ) generated by a compiler such as VC++2008 for a class which does not define them?

  • 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-13T13:59:12+00:00Added an answer on May 13, 2026 at 1:59 pm

    With the clang compiler, you can see them by passing the -ast-dump argument. Clang is still in development stage, but you can already use it for these things:

    [js@HOST2 cpp]$ cat main1.cpp
    struct A { };
    [js@HOST2 cpp]$ clang++ -cc1 -ast-dump main1.cpp
    typedef char *__builtin_va_list;
    struct A {
    public:
        struct A;
        inline A();
        inline A(struct A const &);
        inline struct A &operator=(struct A const &);
        inline void ~A();
    };
    [js@HOST2 cpp]$
    

    I hope that’s what you asked for. Let’s change the code and look again.

    [js@HOST2 cpp]$ cat main1.cpp
    struct M { M(M&); };
    struct A { M m; };
    [js@HOST2 cpp]$ clang++ -cc1 -ast-dump main1.cpp
    typedef char *__builtin_va_list;
    struct M {
    public:
        struct M;
        M(struct M &);
        inline struct M &operator=(struct M const &);
        inline void ~M();
    };
    struct A {
    public:
        struct A;
        struct M m;
        inline A();
        inline A(struct A &);
        inline struct A &operator=(struct A const &);
        inline void ~A();
    };
    [js@HOST2 cpp]$
    

    Notice how the implicitly declared copy constructor of A now has a non-const reference parameter, because one of its members has too (member m), and that M has no default constructor declared.

    For getting the generated code, you can let it emit virtual machine intermediate language. Let’s look on the generated code for this:

    struct A { virtual void f(); int a; };
    A f() { A a; a = A(); return a; } // using def-ctor, assignment and copy-ctor
    
    [js@HOST2 cpp]$ clang++ -cc1 -O1 -emit-llvm -o - main1.cpp | c++filt
    [ snippet ]
    define linkonce_odr void @A::A()(%struct.A* nocapture %this) nounwind align 2 {
    entry:
      %0 = getelementptr inbounds %struct.A* %this, i32 0, i32 0 ; <i8***> [#uses=1]
      store i8** getelementptr inbounds ([3 x i8*]* @vtable for A, i32 0, i32 2), i8*** %0
      ret void
    }
    
    define linkonce_odr %struct.A* @A::operator=(A const&)(%struct.A* %this, 
      %struct.A* nocapture) nounwind align 2 {
    entry:
      %tmp = getelementptr inbounds %struct.A* %this, i32 0, i32 1 ; <i32*> [#uses=1]
      %tmp2 = getelementptr inbounds %struct.A* %0, i32 0, i32 1 ; <i32*> [#uses=1]
      %tmp3 = load i32* %tmp2                         ; <i32> [#uses=1]
      store i32 %tmp3, i32* %tmp
      ret %struct.A* %this
    }
    
    define linkonce_odr void @A::A(A const&)(%struct.A* nocapture %this, %struct.A* nocapture) 
      nounwind align 2 {
    entry:
      %tmp = getelementptr inbounds %struct.A* %this, i32 0, i32 1 ; <i32*> [#uses=1]
      %tmp2 = getelementptr inbounds %struct.A* %0, i32 0, i32 1 ; <i32*> [#uses=1]
      %tmp3 = load i32* %tmp2                         ; <i32> [#uses=1]
      store i32 %tmp3, i32* %tmp
      %1 = getelementptr inbounds %struct.A* %this, i32 0, i32 0 ; <i8***> [#uses=1]
      store i8** getelementptr inbounds ([3 x i8*]* @vtable for A, i32 0, i32 2), i8*** %1
      ret void
    }
    

    Now, i don’t understand that intermediate language (which is defined at llvm.org). But you can translate all that code into C using the llvm compiler:

    [js@HOST2 cpp]$ clang++ -cc1 -O1 -emit-llvm -o - main1.cpp | llc -march=c -o - | c++filt
    [snippet]
    void A::A()(struct l_struct.A *llvm_cbe_this) {
      *((&llvm_cbe_this->field0)) = ((&_ZTV1A.array[((signed int )2u)]));
      return;
    }
    
    
    struct l_struct.A *A::operator=(A const&)(struct l_struct.A *llvm_cbe_this, struct l_struct.A
      *llvm_cbe_tmp__1) {
      unsigned int llvm_cbe_tmp3;
    
      llvm_cbe_tmp3 = *((&llvm_cbe_tmp__1->field1));
      *((&llvm_cbe_this->field1)) = llvm_cbe_tmp3;
      return llvm_cbe_this;
    }
    
    
    void A::A(A const&)(struct l_struct.A *llvm_cbe_this, struct l_struct.A *llvm_cbe_tmp__2) {
      unsigned int llvm_cbe_tmp3;
    
      llvm_cbe_tmp3 = *((&llvm_cbe_tmp__2->field1));
      *((&llvm_cbe_this->field1)) = llvm_cbe_tmp3;
      *((&llvm_cbe_this->field0)) = ((&_ZTV1A.array[((signed int )2u)]));
      return;
    }
    

    Tada! Notice how it sets the virtual table pointer in the copy constructor and default constructor. Hope this helps.

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

Sidebar

Ask A Question

Stats

  • Questions 378k
  • Answers 378k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use CASE: SELECT SUM(CASE col1 WHEN 1 THEN 1 ELSE… May 14, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer Known issue, ruled "Not A Defect". http://std.dkuug.dk/jtc1/sc22/wg21/docs/lwg-closed.html#84 May 14, 2026 at 9:17 pm
  • Editorial Team
    Editorial Team added an answer If you just want a plain-text representation of your (pre-formatted)… May 14, 2026 at 9:17 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.