This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/5284: missing warning on uninitialized variable
- From: peter dot barth at t-online dot de
- To: gcc-gnats at gcc dot gnu dot org
- Date: 5 Jan 2002 09:31:27 -0000
- Subject: c++/5284: missing warning on uninitialized variable
- Reply-to: peter dot barth at t-online dot de
>Number: 5284
>Category: c++
>Synopsis: missing warning on uninitialized variable
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jan 05 01:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: peter.barth@t-online.de
>Release: gcc-2.95.3, gcc-3.0
>Organization:
>Environment:
SuSe Linux 7.3
>Description:
GCC should issue a warning on
int j = (j < 0) ? -i : i;
that j is used uninitialized (some other compilers do).
Complete code snippet
---
#include <iostream>
using namespace std;
int f(int i)
{
int j = (j < 0) ? -i : i; // shouldn't that generate a warning that j is used uninitialized
return j;
}
int main()
{
int h = 3;
cout << h << " " << f(h) << "\n";
h = -3;
cout << h << " " << f(h) << "\n";
return 0;
}
---
>How-To-Repeat:
#include <iostream>
using namespace std;
int f(int i)
{
int j = (j < 0) ? -i : i; // shouldn't that generate a warning that j is used uninitialized
return j;
}
int main()
{
int h = 3;
cout << h << " " << f(h) << "\n";
h = -3;
cout << h << " " << f(h) << "\n";
return 0;
}
>Fix:
???
>Release-Note:
>Audit-Trail:
>Unformatted: