Skip to content

Warning for use of unconditionally uninitialized objects #47

Description

@DavidPH

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) {}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions