This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/450: global variable treated as a local variable.
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/450: global variable treated as a local variable.
- From: rsandova at cis dot ohio-state dot edu
- Date: 7 Aug 2000 19:06:42 -0000
- Reply-To: rsandova at cis dot ohio-state dot edu
- Resent-Cc: gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, jason at gcc dot gnu dot org
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, rsandova@cis.ohio-state.edu
>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: