This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/450: global variable treated as a local variable.



>Number:         450
>Category:       c++
>Synopsis:       global variable treated as a local variable.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 07 12:16:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     rsandova@cis.ohio-state.edu
>Release:        unknown-1.0
>Organization:
>Environment:
% uname -a
SunOS eta 5.6 Generic_105181-13 sun4u sparc SUNW,Ultra-4
>Description:
Expecting variable i to change, but does not.


/*
 * Rene Sandoval
 *
 * Description:
 * This proc should generate a list of random
 * numbers of a fixed size length 3-digits.
 *
 */

#include <iostream>
#include <fstream>
//needed for random function.
#include <stdlib.h>

void main()
{
        int count = 25;
        int i;

        ofstream outputfile;
        char* file_name = new char[30];

        char c = 'y';
        while ('y' == c)
        {
                cout << "Enter a file name:\n";
                cin >> file_name;
                outputfile.open(file_name);     
                cout << file_name << endl;

                i = random();
                cout << "Random#: " << i << endl;

                while (i > 1000)
                {
                    //debug
                    cout << i << endl;
                    i/10;
                }
                outputfile << i << endl;
                cout << "Continue testing (y|n):\n";
                cin >> c;
        }
        outputfile.close ();
        return 0;
}

>How-To-Repeat:
save given code as generator.cpp
then compile using g++ -o gen generator.cpp
run the executable file gen
provide any file for output.
>Fix:

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]