c++/5284: missing warning on uninitialized variable
peter.barth@t-online.de
peter.barth@t-online.de
Sat Jan 5 01:36:00 GMT 2002
>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:
More information about the Gcc-bugs
mailing list