This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/44547] -Wuninitialized reports false warning in nested switch statements (missed switch optimization)
- 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: 17 Jun 2010 08:37:22 -0000
- Subject: [Bug tree-optimization/44547] -Wuninitialized reports false warning in nested switch statements (missed switch optimization)
- References: <bug-44547-19324@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from manu at gcc dot gnu dot org 2010-06-17 08:37 -------
(In reply to comment #4)
> It seems that optimizing is what's causing the problem: the example compiles
> fine with -O0, but not -On>=1. It also compiles fine when the case values are
> consecutive, which seems telling. My first guess would be to take a look at
> what optimizations are being done to switch statements that have
> non-consecutive-valued cases as opposed to those that have consecutive values.
>
Wuninitialized does not detect as many cases with -O0 than with higher
optimizations. When the cases are consecutive, VRP kicks in and simplifies the
switch. You can check what is going on using -fdump-tree-all-lineno and
inspecting the dumps. n(D) means the uninitialized value of n. When that is
removed, then Wuninitialized will not warn.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44547