public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Reza Habib" <reza@psych.utoronto.ca>
To: "Cygwin Mailing List" <cygwin@sourceware.cygnus.com>
Subject: bug in valarray header
Date: Tue, 31 Aug 1999 23:49:00 -0000	[thread overview]
Message-ID: <000001bedc84$93b10bc0$cf9194d1@newton> (raw)
Message-ID: <19990831234900.YfD8iBB0ER-UWLQ_11FfN9KBwWVxgJS9Siz5pb-ZajE@z> (raw)

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 +
IMAGEFILESIZE + 1).front()),IMAGEFILESIZE);

        //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 >
0.0f])).size());

        //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
n

Program received signal SIGSEGV, Segmentation fault.
0x41a279 in LM786 ()
    at
//D/Mingw32/bin/../lib/gcc-lib/i386-mingw32/2.95/../../../../include/g++-
3/std/std_valarray.h:266
266
//D/Mingw32/bin/../lib/gcc-lib/i386-mingw32/2.95/../../../../include/g++
-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.

Reza


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

             reply	other threads:[~1999-08-31 23:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-01 18:13 Reza Habib [this message]
1999-08-31 23:49 ` Reza Habib

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000001bedc84$93b10bc0$cf9194d1@newton' \
    --to=reza@psych.utoronto.ca \
    --cc=cygwin@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).