Thread overview
optimizations?
Jan 19, 2002
Pavel Minayev
Jan 19, 2002
Walter
Jan 19, 2002
Pavel Minayev
Jan 20, 2002
Walter
January 19, 2002
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 =)



January 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 =)
>
>
>


January 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. -Walter

Yes, I know. But what's the reason in checking invariant for a function that does nothing? =) I think this should be optimized away...


January 20, 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...
>
> > What's happening is that a call to the class invariant is made at the beginning and end of each public member function. -Walter
>
> Yes, I know. But what's the reason in checking invariant for a function that does nothing? =) I think this should be optimized away...

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.