https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105237
Bug ID: 105237
Summary: Missing uninitialized warning in self-initialization
case
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: nojus.gudinavicius at gmail dot com
Target Milestone: ---
Created attachment 52789
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52789&action=edit
Reproducer source code
Sorry if this is a dup of bug 18501. The other samples seemed to follow
different pattern than mine so I decided to post separately. Anyway:
$ cat t.c
#include <stdio.h>
#include <stdlib.h>
int negate(int n) { return -n; }
void doexit() { exit(0); }
void test() {
int n;
while ((n=1) > 0) {
int n = negate(n); // n used before initialization
printf("%d\n", n);
doexit();
}
}
int main() {
test();
}
$ gcc -Wall t.c # no warning. replacing doexit call with break shows the
warning
Without the function call the reproducer is smaller, although maybe less likely
to be run into:
int n;
{
int n = n;
printf("%d\n", n);
}