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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Blocks|                            |24639

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
GCC returns zero from f() and expands the conditional and the uninitialized
load in g().  Clang optimizes both functions into just a return instruction
(leaving the result unspecified) without issuing a warning.  Its static
analyzer detects both bugs:

z.c:5:3: warning: Undefined or garbage value returned to caller
[core.uninitialized.UndefReturn]

  return *p;   // -Wuninitialized

  ^~~~~~~~~

z.c:14:3: warning: Undefined or garbage value returned to caller
[core.uninitialized.UndefReturn]

  return p->i;   // missing -Wuninitialized

  ^~~~~~~~~~~

2 warnings generated.

Compiler returned: 0


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues

Reply via email to