This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/45468] gcc does not warn about missing `-O' flag when specifying `-Wuninitialized'
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Aug 2010 21:07:47 -0000
- Subject: [Bug c/45468] gcc does not warn about missing `-O' flag when specifying `-Wuninitialized'
- References: <bug-45468-16461@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #13 from manu at gcc dot gnu dot org 2010-08-31 21:07 -------
(In reply to comment #12)
> Sorry Andrew, misinterpreted some things you said. I understand now that you
> meant that normally everything should work as expected.
>
> @Manuel,
> So, perhaps then this bug report is at least sort of valid? It seems that to
> get `-Wuninitialized' to *fully* work, one would need at least `-O1'?
No, higher levels of optimization may provide even better warnings (or disable
some false positives)
> It seems to me, that if that is the case, and the user has not specified *any*
> `-O'-like option on the command-line, GCC should warn, since it's probably the
> user's intent to get a *fully* working `-Wuninitialized' option? If however,
There is no such thing as a *fully* working Wuninitialized. The results totally
depend on which optimization passes are run (and their order). See
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings for more background on
the issues involved and existing bugs.
> the user did specify `-O0', perhaps GCC should assume the user has knowledge
> about GCC not being able to warn about every case?
Old gcc versions warned because Wuninitialized did nothing without
optimization. The user should know that GCC is not able to warn about every
case at any optimization level, but higher optimization levels should provide
better results (this is what the manual says!). No amount of analysis will warn
about every case (the usual halting problem).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45468