public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: neojack99@hotmail.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/10407: non-numeric assignment to for initialzation cause seg fault
Date: Mon, 14 Apr 2003 21:46:00 -0000	[thread overview]
Message-ID: <20030414214401.2629.qmail@sources.redhat.com> (raw)


>Number:         10407
>Category:       c++
>Synopsis:       non-numeric assignment to for initialzation cause seg fault
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 14 21:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     neojack99@hotmail.com
>Release:        gcc version 3.2.2 20030322 (Gentoo Linux 1.4 3.2.2-r2)
>Organization:
>Environment:
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/specs
Configured with: /var/tmp/portage/gcc-3.2.2-r2/work/gcc-3.2.2/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.2 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.2 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.2/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.2/info --enable-shared --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib --enable-languages=c,c++,ada,f77,objc,java --enable-threads=posix --enable-long-long --disable-checking --enable-cstdio=stdio --enable-clocale=generic --enable-__cxa_atexit --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext
Thread model: posix
>Description:
the code below compiles fine, but segfaults on the for loop - particularly the "int i = non-number" part.
Compiled as:
g++ for_seg_faulter.cpp -o for_seg_faulter

* Note: itdoes not seg fault with icc.

Sample code:

#include <string>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

int main() {
  vector<string> v;

  ifstream in("for_seg_faulter.cpp");
  string line;
  while(getline(in, line))
    v.push_back(line); // Add the line to the end

  //
  for(int i = v.size(); i >= 0 ; i--)
 //Using the actual v.size (21) works. As it is it seg faults.
    cout << i + 1 << ": " << v[i] << endl;
}
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2003-04-14 21:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-14 21:46 neojack99 [this message]
2003-04-14 21:56 bangerth

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=20030414214401.2629.qmail@sources.redhat.com \
    --to=neojack99@hotmail.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /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).