Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning for use of unconditionally uninitialized objects #47

Open
DavidPH opened this issue Apr 17, 2019 · 0 comments
Open

Warning for use of unconditionally uninitialized objects #47

DavidPH opened this issue Apr 17, 2019 · 0 comments

Comments

@DavidPH
Copy link
Owner

DavidPH commented Apr 17, 2019

Code which reads an object which could not have been initialized prior to being read should issue a warning. Such as:

int i = i;
int i;
int j + i + 10;
int i;
if(i) {}

Tracking and warning for potentially uninitialized reads would be nice, but there would certainly be false positives. Still, if it proves reasonably simple, these should also issue a warning at high warn level:

int i;
if(cond())
   i = 10;
int j = i * 7;

The following, however, should not issue any warning:

void *p = &p; // Valid and well-defined.
int i, k;
int j = cond();
if(j)
   i = 10;
if(j)
   k = i + 6; // Has the same condition as the initialization.
else
   k = 42;
int i; // GDCC is not advanced enough to second-guess labels and goto usage.
label: if(i) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant