Bug 704043 - Warning for uninitialized var has the wrong function and location
Summary: Warning for uninitialized var has the wrong function and location
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 27
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-05-11 23:05 UTC by Josh Stone
Modified: 2018-11-30 18:16 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-30 18:16:20 UTC
Type: ---


Attachments (Terms of Use)

Description Josh Stone 2011-05-11 23:05:38 UTC
Description of problem:
In a warning for an uninitialized variable in my program, I was confused because the named variable did not exist in the given function or at the given line.  It turned out to be from a static function that was inlined near that location.

Version-Release number of selected component (if applicable):
gcc-4.6.0-7.fc15.x86_64

How reproducible:
100%

Steps to Reproduce:
1. cat uninit.c
static int bar (void)
{
  int x, y = baz();
  if (y) x = y;
  return x;
}

int foo (void)
{
  return bar ();
}


2. gcc -Wuninitialized -O -c uninit.c

  
Actual results:
$ gcc -Wuninitialized -O -c uninit.c
uninit.c: In function ‘foo’:
uninit.c:10:3: warning: ‘x’ may be used uninitialized in this function [-Wuninitialized]

Expected results:
It should name the function and line where 'x' actually exists.  It works correctly without inlining:
$ gcc -Wuninitialized -O -c uninit.c -fno-inline
uninit.c: In function ‘bar’:
uninit.c:5:3: warning: ‘x’ may be used uninitialized in this function [-Wuninitialized]


Additional info:
For comparison, gcc-4.5.1-4.fc14.x86_64 gets the line closer, though at the point of x's declaration rather than use, but still misses the function name.
$ gcc -Wuninitialized -O -c uninit.c
uninit.c: In function ‘foo’:
uninit.c:3:7: warning: ‘x’ may be used uninitialized in this function
uninit.c:3:7: note: ‘x’ was declared here
$ gcc -Wuninitialized -O -c uninit.c -fno-inline
uninit.c: In function ‘bar’:
uninit.c:3:7: warning: ‘x’ may be used uninitialized in this function

Comment 1 Debarshi Ray 2011-06-15 13:44:34 UTC
The warning disappears when compiled as:
gcc -Wuninitialized -c uninit.c

It should still be there, isn't it?

Comment 2 Josh Stone 2011-06-15 15:42:54 UTC
(In reply to comment #1)
> The warning disappears when compiled as:
> gcc -Wuninitialized -c uninit.c
> 
> It should still be there, isn't it?

No, I think -O is needed to detect uninitialized.  GCC(1) says:
"Because these warnings depend on optimization, the exact variables or elements for which there are warnings will depend on the precise optimization options and version of GCC used."

Comment 3 Fedora End Of Life 2012-08-07 16:24:56 UTC
This message is a notice that Fedora 15 is now at end of life. Fedora
has stopped maintaining and issuing updates for Fedora 15. It is
Fedora's policy to close all bug reports from releases that are no
longer maintained. At this time, all open bugs with a Fedora 'version'
of '15' have been closed as WONTFIX.

(Please note: Our normal process is to give advanced warning of this
occurring, but we forgot to do that. A thousand apologies.)

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, feel free to reopen
this bug and simply change the 'version' to a later Fedora version.

Bug Reporter: Thank you for reporting this issue and we are sorry that
we were unable to fix it before Fedora 15 reached end of life. If you
would still like to see this bug fixed and are able to reproduce it
against a later version of Fedora, you are encouraged to click on
"Clone This Bug" (top right of this page) and open it against that
version of Fedora.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

The process we are following is described here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 4 Josh Stone 2012-08-09 01:05:49 UTC
(In reply to comment #0)
> $ gcc -Wuninitialized -O -c uninit.c
> uninit.c: In function ‘foo’:
> uninit.c:10:3: warning: ‘x’ may be used uninitialized in this function
> [-Wuninitialized]

This is still wrong on F17 too:

$ rpm -q gcc
gcc-4.7.0-5.fc17.x86_64
$ gcc -Wuninitialized -O -c uninit.c
uninit.c: In function ‘foo’:
uninit.c:10:3: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Comment 5 Fedora End Of Life 2013-07-04 05:52:07 UTC
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '17'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 17's end of life.

Bug Reporter:  Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 17 is end of life. If you 
would still like  to see this bug fixed and are able to reproduce it 
against a later version  of Fedora, you are encouraged  change the 
'version' to a later Fedora version prior to Fedora 17's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 6 Fedora End Of Life 2013-08-01 17:08:54 UTC
Fedora 17 changed to end-of-life (EOL) status on 2013-07-30. Fedora 17 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 7 Josh Stone 2013-08-20 21:01:58 UTC
(In reply to Fedora End Of Life from comment #6)
> If you can reproduce this bug against a currently maintained version of 
> Fedora please feel free to reopen this bug against that version.

The issue remains in gcc-4.8.1-1.fc19.x86_64.

Comment 8 Fedora End Of Life 2015-01-09 21:49:17 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 9 Josh Stone 2015-01-09 23:12:09 UTC
$ rpm -q gcc
gcc-4.9.2-1.fc21.x86_64

$ gcc -Wuninitialized -O -c uninit.c
uninit.c: In function ‘foo’:
uninit.c:10:3: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   return bar ();
   ^

$ gcc -Wuninitialized -O -c uninit.c -fno-inline
uninit.c: In function ‘bar’:
uninit.c:5:3: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   return x;
   ^

Comment 10 Fedora End Of Life 2015-11-04 15:45:26 UTC
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '21'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 21 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 11 Josh Stone 2015-11-04 19:45:08 UTC
$ rpm -q gcc
gcc-5.1.1-4.fc23.x86_64

$ gcc -Wuninitialized -O -c uninit.c
uninit.c: In function ‘bar’:
uninit.c:3:14: warning: implicit declaration of function ‘baz’ [-Wimplicit-function-declaration]
   int x, y = baz();
              ^
uninit.c: In function ‘foo’:
uninit.c:10:10: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   return bar ();
          ^

$ gcc -Wuninitialized -O -c uninit.c -fno-inline
uninit.c: In function ‘bar’:
uninit.c:3:14: warning: implicit declaration of function ‘baz’ [-Wimplicit-function-declaration]
   int x, y = baz();
              ^
uninit.c:5:10: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   return x;
          ^

It didn't hit "implicit declaration" before - maybe that's new to the default warning set?  But that location is corrent anyway, while "uninitialized" still gets it wrong in the inlined case.

Comment 12 Fedora End Of Life 2016-11-24 10:31:26 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 13 Josh Stone 2016-11-28 18:46:01 UTC
The situation is the same with gcc-6.2.1-2.fc25.x86_64

Comment 14 Fedora End Of Life 2017-11-16 19:40:36 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 15 Josh Stone 2017-11-16 22:51:03 UTC
Still the same with gcc-7.2.1-2.fc27.x86_64

Comment 16 Ben Cotton 2018-11-27 18:12:23 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora  'version' of '27'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 27 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 17 Ben Cotton 2018-11-30 18:16:20 UTC
Fedora 27 changed to end-of-life (EOL) status on 2018-11-30. Fedora 27 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.