[C++-sig] Re: code generation problems

David Abrahams dave at boost-consulting.com
Fri Dec 17 00:00:22 CET 2004


James Mastro wrote:
> I am having a big problem with BPL. When my extension module is compiled by
> bjam I think it is giving me bad code. I have a couple of functions in a C++
> object that have almost the same signature, just slightly different names. I
> have a free function in the extension module for each of these that calls
> into the C++ object:
> 
> MyObject*    gObject;
> void DoSomethingToObject( int data )
> {
>     gObject->DoSomething( data );
> }
> 
> void SomethingElseToObject( int data )
> {
>     gObject->SomethingElse( data );
> }
> 
> gObject is a valid ptr.
> 
> When this code executes, the gObject->DoSomething call actually calls
> gObject->SomethingElse and vise versa! 

If that is in fact the case you are not having a BPL problem at all:
it's simply a compiler bug.  You should reduce the problem to a minimal
case that doesn't involve BPL and post it to a microsoft support
newsgroup or other such resource at this point.

> So I went and changed names thinking
> maybe it was confused by similar names, that didn't help. I went as far as
> to add some bogus parameters to SomethingElse but even that did not work. It
> still happily calls the wrong function even though it was called with a
> different number of parameters. Now I don't trust the VS debugger at all,

I'm surprised; I find it to be very good.

> but as I step through the code everything seems to make sense. It's
> executing the code it's stepping through, it's not just displaying the wrong
> lines of code as it has done before for me.

I'm not sure exactly what you mean by "seems to make sense."  Do you
mean that when you step into the call to DoSomething the PC is shown
somewhere inside the source code to DoSomething?

> Are there any known problems with compiling modules that would lead to
> something like this? I don't even know where to start. I guess I will have
> to try to come up with a small example demonstrating the problem. This is 
> using boost 1.32 with vc-7_1.

Yes, but unless you have a good reason to think this is BPL-related, you
should take your problem elsewhere.  It's not that I'm unsympathetic,
but I don't think there's anything I can do to help you.

Sorry,

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com




More information about the Cplusplus-sig mailing list