RE: [sigc] Unwanted pass-by-value behavior with MSVC++ 7.1



Murray Cumming wrote:
>
> > Basically sigc::bind somehow was causing arguments to be 
> > passed by value even when explicitly told to pass by 
> > reference. (I verified this by passing an object by 
> > reference that had a private copy-constructor and 
> > getting a compile-time error.  Also, test_lambda was 
> > producing incorrect results [....]
> 
> A test case for this would be really useful. We could add 
> it to the tests directory. In bugzilla please.

Okay, will do sometime this week.

To elaborate on the test_lambda case, before I disabled the
sun_forte_workaround calls with MSVC++, lines 69-71 in test_lambda.cc
produced (with optimizations enabled):

  ((++_1)*2)(ref(a)): 4; a: 1
  ((++(*_1))*2)(&a):  4; a: 2
  ((--(*(&_1)))*2)(ref(a)): 2; a: 2

(AFAICT, the correct values should be (4, 2), (6, 3), and (4, 2)
respectively.)

> > and that SIGC_WORKAROUND_OPERATOR_PARENTHESES and 
> > LIBSIGC_TEMPLATE_PREFIX really do need their own, 
> > independent tests.
> 
> Yes, and I guess you are the best person to implement them. 
> It's really quite simple, because there is already an example. 
> You need to 
> 
> 1. Add an .m4 macro in scripts/cxx.m4. Copy the existing one 
> and change
> [...]

Okay, but I'm not sure how useful that would be to Windows MSVC++ users, the
people who'd encounter the problem.  Are MSVC++ users expected to run the
configure script?

> Please tell me if you have any problems. Unfortunately, I 
> don't think a check for WIN32 will be good enough, because there 
> are now several versions of the MSVC++ compiler in common use, 
> each with different capabilities.

That's true.  On the plus side, Microsoft has made the VC++7.1/VC++2003
compiler available for free, and it can be installed alongside an existing
Visual Studio installation.  Plus, the Visual Studio project files included
with libsigc++ 2.0.3 already require VS.net 2003 anyway.

- James



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]