https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104270

            Bug ID: 104270
           Summary: -Wanalyzer-use-of-uninitialized-value is incorrectly
                    suppressed by -ftrivial-auto-var-init=
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

As of GCC 12, the analyzer ought to complain about uses of uninitialized memory
via
  -Wanalyzer-use-of-uninitialized-value 
but fails to do so for trivial cases of locals when -ftrivial-auto-var-init= is
used with "pattern" or "zero".

The docs for -ftrivial-auto-var-init say:

> GCC still considers an automatic variable that doesn't have an explicit
> initializer as uninitialized, @option{-Wuninitialized} will still report
> warning messages on such automatic variables.

which implies that -ftrivial-auto-var-init is intended for mitigation, and that
the analyzer ought to still warn on such cases.

At the gimple level we have e.g.:

  i_1 = .DEFERRED_INIT (4, 1, &"i"[0]);

which the analyzer doesn't yet have any special knowledge about, and thus
treats the result as a normal value, suppressing the warning.

Reply via email to