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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
It is true that if there is no edge to the label there is no guarantee where
exactly it will wind up, but we make quite a lot of effort to emit it as a
reasonable spot if possible (see NOTE_INSN_DELETED_LABEL etc.).

That said, -Wdangling-pointer* description is quite clear:
Warn about uses of pointers (or C++ references) to objects with automatic
storage duration after their lifetime has ended.

Labels aren't automatic storage duration objects, they are code addresses but
if anything, they could be more compared to static function-scope variables,
-Wdangling-pointer* doesn't warn about those either.

A lot of programs in the wild actually do use &&label for just printing
addresses, not just the kernel, and we shouldn't warn on it in any way,
especially not with completely unrelated warning.  We can warn if we can prove
somebody is actually trying to jump through them into statement expressions and
the like, but that is not what happens here.

The bug is clearly in
/* Return true of X is a DECL with automatic storage duration.  */

static inline bool
is_auto_decl (tree x)
{
  return DECL_P (x) && !DECL_EXTERNAL (x) && !TREE_STATIC (x);
}

That function should be killed and auto_var_p function should be used instead.

Reply via email to