public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cjedic at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/66267] New: internal compiler error: Segmentation fault
Date: Sat, 23 May 2015 21:50:00 -0000	[thread overview]
Message-ID: <bug-66267-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66267

            Bug ID: 66267
           Summary: internal compiler error: Segmentation fault
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cjedic at gmail dot com
  Target Milestone: ---

I got the following segmentation fault from the following code:

..\calcGrades.cpp:32:3: internal compiler error: Segmentation fault
   }
   ^

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

struct grades
         {
                 string firstName;
                 string lastName;
                 int    ID;
                 int    prgmGrades[10];
                 int    examGrades[3];
                 int    fexamGrade;
                 double finalGrade;
         }student;

 double calculatePercentGrade(const grades person)
  {
         int total = 0;
         double pAvg, eAvg, fAvg, final;
         for(int i = 0; i < 10; i++)
                 total += person.prgmGrades[i];
         pAvg = total/10;
         total = 0;
         for(int i = 0; i < 3; i++)
                         total += person.examGrades[i];
         eAvg = total/3;
         fAvg = person.fexamGrade;
         final = (pAvg * 0.3) + (eAvg * 0.45) + (fAvg * 0.25);
         return final;
  }
  char calculateLetterGrade(const double percent)
  {
         if(percent < 60)
                 return 'F';
         else if(percent < 70)
                 return 'D';
         else if(percent < 80)
                 return 'C';
         else if (percent < 90)
                 return 'B';
         else
                 return 'A';
  }

 int main()
 {


         ifstream fin("gradeBook.txt");
         char letterGrade;


         cout << "This program reads a data file of student grades, calculates
the \n"
                  << "final grade, and displays the student’s name and final
grade.\n\n\n";
         cout << "           Final Grades \n\n";
         while(!fin.eof())
         {
                 fin >> student.firstName >> student.lastName >> student.ID;
                 for(int i = 0; i < 0; i++)
                         fin >> student.prgmGrades[i];
                 for(int i = 0; i< 3; i++)
                         fin >> student.examGrades[i];
                 fin >> student.fexamGrade;
                 student.finalGrade = calculatePercentGrade(student);
                 letterGrade = calculateLetterGrade(student.finalGrade);
                 cout << student.firstName << ' ' << student.lastName  <<
"\t\t"
                          << letterGrade << '\n';
         }

        return 0;
 }
>From gcc-bugs-return-487158-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat May 23 22:29:31 2015
Return-Path: <gcc-bugs-return-487158-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 53816 invoked by alias); 23 May 2015 22:29:31 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 53750 invoked by uid 55); 23 May 2015 22:29:26 -0000
From: "nathan at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/65936] [6 Regression] ICE: canonical types differ for identical types
Date: Sat, 23 May 2015 22:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: nathan at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: nathan at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-65936-4-0bKHecwVi7@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65936-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65936-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-05/txt/msg01998.txt.bz2
Content-length: 594

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide936

--- Comment #3 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
Author: nathan
Date: Sat May 23 22:28:54 2015
New Revision: 223613

URL: https://gcc.gnu.org/viewcvs?rev"3613&root=gcc&view=rev
Log:
        cp/
        PR c++/65936
        * pt.c (lookup_template_class_1): Copy may_alias attribute too.

        testsuite/
        PR c++/65936
        * g++.dg/template/pr65936.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/template/pr65936.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


             reply	other threads:[~2015-05-23 21:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-23 21:50 cjedic at gmail dot com [this message]
2015-05-23 22:29 ` [Bug c++/66267] " glisse at gcc dot gnu.org
2015-05-24 16:48 ` cjedic at gmail dot com
2015-05-24 16:48 ` cjedic at gmail dot com
2015-05-24 16:49 ` daniel.kruegler at googlemail dot com

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=bug-66267-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).