D - optimizations?
- Pavel Minayev (11/11) Jan 19 2002 The following program was compiled with optimizations
- Walter (4/15) Jan 19 2002 What's happening is that a call to the class invariant is made at the
- Pavel Minayev (5/7) Jan 19 2002 Yes, I know. But what's the reason in checking invariant for
- Walter (7/14) Jan 19 2002 Ah, a very good question. And the answer (!) is that if that function is
The following program was compiled with optimizations turned on (-O), but in debug mode (no -release): class foo { void bar() { } } Compiler generated the following assembler code: L0: call near ptr _Dinvariant__d_invariant_FC6ObjectZv call near ptr _Dinvariant__d_invariant_FC6ObjectZv ret ROTFL =)
Jan 19 2002
What's happening is that a call to the class invariant is made at the beginning and end of each public member function. -Walter "Pavel Minayev" <evilone omen.ru> wrote in message news:a2bq13$10i8$1 digitaldaemon.com...The following program was compiled with optimizations turned on (-O), but in debug mode (no -release): class foo { void bar() { } } Compiler generated the following assembler code: L0: call near ptr _Dinvariant__d_invariant_FC6ObjectZv call near ptr _Dinvariant__d_invariant_FC6ObjectZv ret ROTFL =)
Jan 19 2002
"Walter" <walter digitalmars.com> wrote in message news:a2cdql$1ep3$1 digitaldaemon.com...What's happening is that a call to the class invariant is made at the beginning and end of each public member function. -WalterYes, I know. But what's the reason in checking invariant for a function that does nothing? =) I think this should be optimized away...
Jan 19 2002
"Pavel Minayev" <evilone omen.ru> wrote in message news:a2ched$1h26$1 digitaldaemon.com..."Walter" <walter digitalmars.com> wrote in message news:a2cdql$1ep3$1 digitaldaemon.com...Ah, a very good question. And the answer (!) is that if that function is invoked via a pointer to a derived class object, then the invariant for that derived class needs to be run. You could argue that it doesn't need it on both entry and exit since no code is executed between them. You'd be correct.What's happening is that a call to the class invariant is made at the beginning and end of each public member function. -WalterYes, I know. But what's the reason in checking invariant for a function that does nothing? =) I think this should be optimized away...
Jan 19 2002