* [PATCH] c++: Move -Wdangling-reference to -Wextra [PR109642]
@ 2023-05-01 23:54 Marek Polacek
2023-05-02 18:32 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2023-05-01 23:54 UTC (permalink / raw)
To: Jason Merrill, GCC Patches
Sadly, -Wdangling-reference generates false positives for std::span-like
user classes, and it seems imprudent to attempt to improve the heuristic
in GCC 13. Let's move the warning to -Wextra, that will hopefully
reduce the number of false positives the users have been seeing with 13.
I'm leaving the warning in -Wall in 14 where I think I can write code
to detect std::span-like classes.
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for 13.2?
PR c++/109642
PR c++/109640
PR c++/109671
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.
---
gcc/c-family/c.opt | 2 +-
gcc/doc/invoke.texi | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 3333cddeece..a75038930ae 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -560,7 +560,7 @@ C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_dangling_pointer) Warn
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
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index a38547f53e5..36ed1591440 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -3781,7 +3781,7 @@ where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
both references dangle after the end of the full expression that contains
the call to @code{std::minmax}.
-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
@@ -6126,6 +6126,7 @@ name is still supported, but the newer name is more descriptive.)
@gccoptlist{-Wclobbered
-Wcast-function-type
+-Wdangling-reference @r{(C++ only)}
-Wdeprecated-copy @r{(C++ only)}
-Wempty-body
-Wenum-conversion @r{(C only)}
--
2.40.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: Move -Wdangling-reference to -Wextra [PR109642]
2023-05-01 23:54 [PATCH] c++: Move -Wdangling-reference to -Wextra [PR109642] Marek Polacek
@ 2023-05-02 18:32 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2023-05-02 18:32 UTC (permalink / raw)
To: Marek Polacek, GCC Patches
On 5/1/23 19:54, Marek Polacek wrote:
> Sadly, -Wdangling-reference generates false positives for std::span-like
> user classes, and it seems imprudent to attempt to improve the heuristic
> in GCC 13. Let's move the warning to -Wextra, that will hopefully
> reduce the number of false positives the users have been seeing with 13.
>
> I'm leaving the warning in -Wall in 14 where I think I can write code
> to detect std::span-like classes.
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for 13.2?
OK.
> PR c++/109642
> PR c++/109640
> PR c++/109671
>
> 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.
> ---
> gcc/c-family/c.opt | 2 +-
> gcc/doc/invoke.texi | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
> index 3333cddeece..a75038930ae 100644
> --- a/gcc/c-family/c.opt
> +++ b/gcc/c-family/c.opt
> @@ -560,7 +560,7 @@ C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_dangling_pointer) Warn
> 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
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index a38547f53e5..36ed1591440 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -3781,7 +3781,7 @@ where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
> both references dangle after the end of the full expression that contains
> the call to @code{std::minmax}.
>
> -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
> @@ -6126,6 +6126,7 @@ name is still supported, but the newer name is more descriptive.)
>
> @gccoptlist{-Wclobbered
> -Wcast-function-type
> +-Wdangling-reference @r{(C++ only)}
> -Wdeprecated-copy @r{(C++ only)}
> -Wempty-body
> -Wenum-conversion @r{(C only)}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-02 18:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-01 23:54 [PATCH] c++: Move -Wdangling-reference to -Wextra [PR109642] Marek Polacek
2023-05-02 18:32 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).