Re: VC++ 7.1 (.net 2003) compiler code optimization bug ?
From: Tim Brown (TimBrown_at_discussions.microsoft.com)
Date: 06/23/04
- Next message: Rufus V. Smith: "Re: && operator in while()"
- Previous message: Tim Brown: "Re: VC++ 7.1 (.net 2003) compiler code optimization bug ?"
- In reply to: Victor Bazarov: "Re: VC++ 7.1 (.net 2003) compiler code optimization bug ?"
- Next in thread: Victor Bazarov: "Re: VC++ 7.1 (.net 2003) compiler code optimization bug ?"
- Reply: Victor Bazarov: "Re: VC++ 7.1 (.net 2003) compiler code optimization bug ?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Jun 2004 07:14:01 -0700
"Victor Bazarov" wrote:
>
> Are you sure the problem is due to the compiler bug and not to the fact
> that your code doesn't have any destructor or copy-constructor that could
> affect the behaviour of the program?
>
> It is rather strange that the compiler inlines a call to a function when
> asked to minimize the _size_ of the resulting code. I should rather think
> that it would _not_ inline.
>
> In any case, the way to work around this is to place the constructor in
> a separate translation unit. The compiler will have no way of knowing
> where to get the body, so inlining would be impossible.
>
> V
>
Hi Victor,
Thanks for the reply, in fact my example is a very cut down version of
the bug which I was trying to explain and I think I got the description
wrong, or rather I've finally spotted what is going wrong. So perhaps
I can have another go :-)
If I add another CTypeInfo variable then the code generated looks like this.
CTypeInfo a(10, 20);
00404B48 mov dword ptr [CTypeInfo::s_pList (4072E0h)],offset a (407040h)
00404B52 ret
CTypeInfo b(104, 220);
00404B53 mov eax,dword ptr [CTypeInfo::s_pList (4072E0h)]
00404B58 mov dword ptr [b (40704Ch)],eax
00404B5D mov dword ptr [CTypeInfo::s_pList (4072E0h)],offset b (40704Ch)
00404B67 ret
But the code for the "construction" of variable a is only correct if s_pList
is zero which is it in the source file. However if you add another file which
also defines a CTypeInfo variable (say c) and if it is created first (which
in my case it was) then s_pList will not be zero.
So when the variable a is created its m_pList element will be left as 0
instead of containing the real value of s_pList (ie the address of variable c).
I hope this makes sense and sorry for any confusion.
Tim.
(I've had problems trying to post this reply sorry if it arrives lots of times)
- Next message: Rufus V. Smith: "Re: && operator in while()"
- Previous message: Tim Brown: "Re: VC++ 7.1 (.net 2003) compiler code optimization bug ?"
- In reply to: Victor Bazarov: "Re: VC++ 7.1 (.net 2003) compiler code optimization bug ?"
- Next in thread: Victor Bazarov: "Re: VC++ 7.1 (.net 2003) compiler code optimization bug ?"
- Reply: Victor Bazarov: "Re: VC++ 7.1 (.net 2003) compiler code optimization bug ?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|