3.2.0

John W. Eaton jwe at octave.org
Wed May 20 13:23:11 CDT 2009


On 19-May-2009, Michael Goffioul wrote:

| 2) use a volatile octave_idx_type as argument for const octave_idx_type&
| 
| What's the reason of declaring "i" volatile in this case?
| 
| Michael.
| 
| ../../liboctave/CmplxQR.cc(330) : error C2780: 'const _Ty
| &std::min(const _Ty &,const _Ty &,_Pr)' : expects 3 arguments - 2
| provided
|         C:\Program Files\Microsoft Visual Studio
| 9.0\VC\INCLUDE\xutility(3379) : see declaration of 'std::min'
| ../../liboctave/CmplxQR.cc(330) : error C2782: 'const _Ty
| &std::min(const _Ty &,const _Ty &)' : template parameter '_Ty' is
| ambiguous
|         C:\Program Files\Microsoft Visual Studio
| 9.0\VC\INCLUDE\xutility(3371) : see declaration of 'std::min'
|         could be 'volatile octave_idx_type'
|         or       'octave_idx_type'
| ../../liboctave/CmplxQR.cc(330) : error C2664: 'zqrinc_' : cannot
| convert parameter 2 from 'volatile octave_idx_type' to 'const
| octave_idx_type &'
|         Conversion loses qualifiers
| ../../liboctave/CmplxQR.cc(387) : error C2664: 'zqrdec_' : cannot
| convert parameter 2 from 'volatile octave_idx_type' to 'const
| octave_idx_type &'
|         Conversion loses qualifiers

It's declared volatile to avoid the following warning from GCC:

  g++ -c  -fPIC -I. -I/home/jwe/src/octave/liboctave -I.. -I../liboctave -I../src -I../libcruft/misc -I/home/jwe/src/octave -I/home/jwe/src/octave/liboctave -I/home/jwe/src/octave/src -I/home/jwe/src/octave/libcruft/misc  -DHAVE_CONFIG_H -I/usr/include/freetype2 -Wall -W -Wshadow -Wold-style-cast -Wformat -g -O2 /home/jwe/src/octave/liboctave/CmplxQR.cc -o pic/CmplxQR.o
  /home/jwe/src/octave/liboctave/CmplxQR.cc: In member function 'void ComplexQR::insert_col(const ComplexMatrix&, const Array<int>&)':
  /home/jwe/src/octave/liboctave/CmplxQR.cc:324: warning: variable 'i' might be clobbered by 'longjmp' or 'vfork'

As I understand it, the problem is that the F77_XFCN macro uses
setjmp inside a for loop which uses I again after the call to setjmp.
So if I is placed in a register, it might be invalid if the function
called by F77_XFCN ends up doing a longjmp.  Declaring I as volatile
prevents GCC from placing it in a register, so the value is still
valid after a longjmp.

Does the following change avoid the problem you are seeing?  If so, I
don't have a problem with making changes like this as needed.

jwe

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diffs
Url: https://www-old.cae.wisc.edu/pipermail/octave-maintainers/attachments/20090520/5785968a/attachment.ksh 


More information about the Octave-maintainers mailing list