Hi Paolo, what is happening here is legal C++ (hence a Solaris C++ bug), albeit a little tricky (category obfuscated C++): TMatrix m(2,2); (TMatrixDiag)m = pattern-3; creates a temporary TMatrixDiag object initializes it with m (using TMatrixDiag(const TMatrix &) and applies to the resulting temporary the void TMatrixDiag::operator=(Real_t val) to make the assignement to the diagonal of m. Since a TMatrixDiag works directly on a reference of m we don't mind losing the handle to the diagonal matrix. To make it compile on Solaris make the following changes: cout << "\nCheck modifying the matrix diagonal" << endl; m = pattern; //(TMatrixDiag)m = pattern-3; TMatrixDiag td = m; <----- here td = pattern-3; <----- here Assert( !( m == pattern ) && !( m != pattern ) ); vc = TMatrixDiag(m); verify_element_value(vc,pattern-3); //TMatrixDiag(m) += 3; td += 3; <----- here Assert( m == pattern ); vc = pattern+3; //(TMatrixDiag)m = vc; td = vc; <------ here Assert( !( m == pattern ) && !( m != pattern ) ); I'll change the example so it will also compile on Solaris. Cheers, Fons. Paolo CALAFIURA wrote: > > Hi everybody, > in the test program vvector.cxx that I found in 1.03 distribution I > read: > const Real_t pattern = 8.625; > TMatrix m(0,vsize,0,vsize+1); > ... > m = pattern; > (TMatrixDiag)m = pattern-3; //line 459 > > I am used to be baffled by elegant C++ constructs, but this time the > Solaris compiler is not any better than me: > > na48s01:/afs/cern.ch/user/c/calaf/root/test>gmake > > CC -O -KPIC -I/afs/cern.ch/user/c/calaf/root/include -c vvector.cxx > > "vvector.cxx", line 459: Error: The left operand must be a lvalue. > > "vvector.cxx", line 466: Error: The left operand must be a lvalue. > > "vvector.cxx", line 494: Error: The left operand must be a lvalue. > > 3 Error(s) detected. > > Where is the trick? > > Paolo Calafiura -- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland Phone: +41 22 7679248 E-Mail: Fons.Rademakers@cern.ch Fax: +41 22 7677910
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:29 MET