Despite a number of mitigations (don't warn for std::span-like classes,
lambdas, adding [[gnu::no_dangling]], etc.), the warning still seems to
cause some grief. Let's move the warning to -Wextra, then.
gcc/c-family/ChangeLog:
* c.opt (Wdangling-reference): Move from -Wall to -Wextra.
gcc/ChangeLog:
* doc/invoke.texi: Document that -Wdangling-reference is
enabled by -Wextra.
Warn for uses of pointers to auto variables whose lifetime has ended.
Wdangling-reference
-C++ ObjC++ Var(warn_dangling_reference) Warning LangEnabledBy(C++ ObjC++, Wall)
+C++ ObjC++ Var(warn_dangling_reference) Warning LangEnabledBy(C++ ObjC++, Wextra)
Warn when a reference is bound to a temporary whose lifetime has ended.
Wdate-time
The warning can be disabled by using the @code{gnu::no_dangling} attribute
(@pxref{C++ Attributes}).
-This warning is enabled by @option{-Wall}.
+This warning is enabled by @option{-Wextra}.
@opindex Wdelete-non-virtual-dtor
@opindex Wno-delete-non-virtual-dtor
-Wcalloc-transposed-args
-Wcast-function-type
-Wclobbered
+-Wdangling-reference @r{(C++ only)}
-Wdeprecated-copy @r{(C++ and Objective-C++ only)}
-Wempty-body
-Wenum-conversion @r{(only for C/ObjC)}