public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* g++ compiler generated copy constructor
@ 2014-08-11 17:54 navin p
  2014-08-11 18:18 ` Jędrzej Dudkiewicz
  2014-08-11 19:15 ` Oleg Endo
  0 siblings, 2 replies; 5+ messages in thread
From: navin p @ 2014-08-11 17:54 UTC (permalink / raw)
  To: gcc-help

Hi,
  Is there any way i can see the compiler generated copy constructor
and default constructor/destructor as a .cpp file instead of assembly
? Any flags to g++,

Regards,
Navin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: g++ compiler generated copy constructor
  2014-08-11 17:54 g++ compiler generated copy constructor navin p
@ 2014-08-11 18:18 ` Jędrzej Dudkiewicz
  2014-08-11 19:15 ` Oleg Endo
  1 sibling, 0 replies; 5+ messages in thread
From: Jędrzej Dudkiewicz @ 2014-08-11 18:18 UTC (permalink / raw)
  To: navin p; +Cc: gcc-help

On Mon, Aug 11, 2014 at 7:54 PM, navin p <navinp1281@gmail.com> wrote:
> Hi,
>   Is there any way i can see the compiler generated copy constructor
> and default constructor/destructor as a .cpp file instead of assembly
> ? Any flags to g++,

I don't think so, but I believe that even if you could do it both
constructor and destructor would be empty and copy constructor would
be something like this:

class C {
   Field a, b, c;
public:
   C(const C& rhs) : a(rhs.a), b(rhs.b), c(rhs.c) {}
};

Not much. Though my C++ is rusting, so I'm not completely sure.
-- 
Jędrzej Dudkiewicz

I really hate this damn machine, I wish that they would sell it.
It never does just what I want, but only what I tell it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: g++ compiler generated copy constructor
  2014-08-11 17:54 g++ compiler generated copy constructor navin p
  2014-08-11 18:18 ` Jędrzej Dudkiewicz
@ 2014-08-11 19:15 ` Oleg Endo
  2014-08-11 22:41   ` navin p
  1 sibling, 1 reply; 5+ messages in thread
From: Oleg Endo @ 2014-08-11 19:15 UTC (permalink / raw)
  To: navin p; +Cc: gcc-help

Hello,

On Mon, 2014-08-11 at 23:24 +0530, navin p wrote:
> Hi,
>   Is there any way i can see the compiler generated copy constructor
> and default constructor/destructor as a .cpp file instead of assembly
> ? Any flags to g++,
> 

Since you haven't specified what kind of information you want to have
about the generated functions, one can only guess.
Maybe looking at some of the tree/RTL dumps (try option
-fdump-tree-all-details or -fdump-rtl-all-details see
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#Debugging-Options for details) might contain the information you're looking for.  Notice however, that the generated functions might get optimized away completely after they have been inlined into the caller.

Cheers,
Oleg

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: g++ compiler generated copy constructor
  2014-08-11 19:15 ` Oleg Endo
@ 2014-08-11 22:41   ` navin p
  2014-08-12  9:44     ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: navin p @ 2014-08-11 22:41 UTC (permalink / raw)
  To: Oleg Endo; +Cc: gcc-help

Hi,
   I'm maintaining an old C++ library code (written in around 2002) ,
I get segfaults in constructor. The default constructors are generated
by the compiler. When i compile the program with
fno-elide-constructors it works without any problem ie it runs fine. I
want to see what is happening with the constructor and why it is
segfaulting. It is probably the RVO kicking in and changing the
reference counting the library implements.

Regards,
Navin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: g++ compiler generated copy constructor
  2014-08-11 22:41   ` navin p
@ 2014-08-12  9:44     ` Jonathan Wakely
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Wakely @ 2014-08-12  9:44 UTC (permalink / raw)
  To: navin p; +Cc: Oleg Endo, gcc-help

On 11 August 2014 23:41, navin p wrote:
> Hi,
>    I'm maintaining an old C++ library code (written in around 2002) ,
> I get segfaults in constructor. The default constructors are generated
> by the compiler. When i compile the program with
> fno-elide-constructors it works without any problem ie it runs fine. I
> want to see what is happening with the constructor and why it is
> segfaulting. It is probably the RVO kicking in and changing the
> reference counting the library implements.

What an implicitly-defined constructor does is entirely mechanical,
you shouldn't need to read it to know what it does.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-12  9:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-11 17:54 g++ compiler generated copy constructor navin p
2014-08-11 18:18 ` Jędrzej Dudkiewicz
2014-08-11 19:15 ` Oleg Endo
2014-08-11 22:41   ` navin p
2014-08-12  9:44     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).