bug in valarray header

Reza Habib reza@psych.utoronto.ca
Sun Aug 1 18:13:00 GMT 1999

Hello.  I'm porting a program I've written in borland c++ builder 4.0 to gcc
2.95.  The program uses the valarray classes of the standard c++ library.
The program compiles and runs correctly with borland c++ builder however the
exact same code causes a segmentation fault with gcc.  The culprit line of
source code as revealed by gdb is:

        Mask = Mask && (Image > 0.0f);

Here is the context within which that line occurs:

        //Convert image to float by assigning to valarray
        valarray<float> Image(&(vector<float>(ByteImage,ByteImage +

        //Replace values less than 1/4 of maximum value with 0
        Image[Image <= (Image.max() / 4.0f)] = 0.0f;

        //Ratio normalize image: divide each value by the mean of the image
        Image /= (Image.sum() / (valarray<float>(Image[Image >

        //Update mask with non-zero columns of current image
        Mask = Mask && (Image > 0.0f);

This is the output for gdb:

74              Mask = Mask && (Image > 0.0f);
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x41a279 in LM786 ()
-3/std/std_valarray.h: No such file or directory.

I got no warnings or errors when compiling the code and as I mentioned the
code compiled and ran perfectly when compiled with borland c++ builder 4.
So my guess is that this is a problem with the gcc version of the valarray
header.  Any clues into this matter would be greatly appreciated.  Thanks.


Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

More information about the Cygwin mailing list