User account creation filtered due to spam.

Bug 43459 - Invalid "may be used uninitialized in this function" warning with -Os
Summary: Invalid "may be used uninitialized in this function" warning with -Os
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
Reported: 2010-03-21 02:04 UTC by rwahl
Modified: 2010-03-22 23:56 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description rwahl 2010-03-21 02:04:27 UTC
Simple testcase:


#include <errno.h>
#include <unistd.h>

int testfunc(void)
    int ret;

    while (1) {
	const unsigned int MY_BUF_SIZE = 20;
    	char buf[MY_BUF_SIZE];
	if (read(0, buf, sizeof(buf)) < 0) {
	    ret = errno;
	    goto bail;


    return ret;


With gcc 4.4.3 I get:

$ gcc -Wextra -Wall -Os -c test.c 
test.c: In function ‘testfunc’:
test.c:6: warning: ‘ret’ may be used uninitialized in this function
$ gcc -Wextra -Wall -c test.c 
$ gcc -Wextra -Wall -O -c test.c 
$ gcc -Wextra -Wall -O2 -c test.c 

gcc 4.3.2 did not show this issue.
Comment 1 Manuel López-Ibáñez 2010-03-21 20:23:27 UTC
I cannot reproduce this in GCC 4.5, so probably it got fixed. Thanks for the report.
Comment 2 rwahl 2010-03-22 23:56:55 UTC
Just checked with gcc-4.4 branch HEAD and it works there, too. So it will be in gcc-4.4.4. I hope its released soon... ;-)