Bug 48643 - Improving -Wuninitialized documentation (4.6.0 missed a bug that 3.4.3 caught)
Summary: Improving -Wuninitialized documentation (4.6.0 missed a bug that 3.4.3 caught)
Status: RESOLVED DUPLICATE of bug 18501
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-16 19:14 UTC by Paul Eggert
Modified: 2012-10-24 23:57 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Eggert 2011-04-16 19:14:10 UTC
I use GCC to catch bugs in Emacs source code involving uninitialized
variables, and found, to my surprise, that GCC 4.6.0 missed a bug that
GCC 3.4.3 caught.  It took me a while to figure out what was wrong
with the code, and I'd like to suggest better documentation to warn
programmers about this.

In the Debugging Options node, under -Wuninitialized,
the GCC 4.6.0 manual says this:

     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.

Could you please improve the documentation by adding the following text?

     The warnings detect all local variables that might be used
     uninitialized in the code produced by this particular use of GCC,
     but they do not necessarily warn about similar problems that
     might occur in other compilations.  Here is an example:

	int
	bad_function (int n)
	{
	  int c;
	  if (n > 0)
	    c = 0;
	  return c;
	}

     If GCC optimizes this function's entire body away to "return 0;",
     GCC may not report the possibly-uninitialized variable, even
     thought the code may cause problems when the same function is
     compiled with lesser optimization or by a different compiler.
Comment 1 Manuel López-Ibáñez 2012-10-24 23:57:21 UTC
This is also bug 18501.

There are many ways in which optimizations may prevent the warning being issued. Just look at how many open bugs are listed in PR24639. The current text seems to say exactly this. But if you think your text is adding something not in the current documentation, please submit a patch to gcc-patches@gcc.gnu.org.

*** This bug has been marked as a duplicate of bug 18501 ***