* [Bug middle-end/102633] [11/12 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
@ 2021-10-06 21:42 ` msebor at gcc dot gnu.org
2021-10-06 21:47 ` msebor at gcc dot gnu.org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-10-06 21:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|warning for |[11/12 Regression] warning
|self-initialization despite |for self-initialization
|-Wno-init-self |despite -Wno-init-self
Keywords| |diagnostic
Blocks| |24639
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The suppression has worked until GCC 10.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
[Bug 24639] [meta-bug] bug to track all Wuninitialized issues
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
2021-10-06 21:42 ` [Bug middle-end/102633] [11/12 Regression] " msebor at gcc dot gnu.org
@ 2021-10-06 21:47 ` msebor at gcc dot gnu.org
2021-10-07 9:02 ` rguenth at gcc dot gnu.org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-10-06 21:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |muecker at gwdg dot de
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Bisection points to g:32934a4f45a72144cdcd0712cc294fe88c36f13d.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
2021-10-06 21:42 ` [Bug middle-end/102633] [11/12 Regression] " msebor at gcc dot gnu.org
2021-10-06 21:47 ` msebor at gcc dot gnu.org
@ 2021-10-07 9:02 ` rguenth at gcc dot gnu.org
2022-04-21 7:50 ` rguenth at gcc dot gnu.org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-07 9:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (2 preceding siblings ...)
2021-10-07 9:02 ` rguenth at gcc dot gnu.org
@ 2022-04-21 7:50 ` rguenth at gcc dot gnu.org
2022-07-26 13:25 ` [Bug middle-end/102633] [11/12/13 " rguenth at gcc dot gnu.org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21 7:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.3 |11.4
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12/13 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (3 preceding siblings ...)
2022-04-21 7:50 ` rguenth at gcc dot gnu.org
@ 2022-07-26 13:25 ` rguenth at gcc dot gnu.org
2022-07-26 14:09 ` mpolacek at gcc dot gnu.org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-26 13:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2022-07-26
Priority|P3 |P2
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Re-confirmed. For volatiles whether they are uninitialized ever is a separate
question...
Martin - can you try addressing bugs your changes cause?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12/13 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (4 preceding siblings ...)
2022-07-26 13:25 ` [Bug middle-end/102633] [11/12/13 " rguenth at gcc dot gnu.org
@ 2022-07-26 14:09 ` mpolacek at gcc dot gnu.org
2022-07-26 14:28 ` mpolacek at gcc dot gnu.org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-07-26 14:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The problem is that since the patch above, we create a NOP_EXPR:
2172 if (convert_p && !error_operand_p (exp.value)
2173 && (TREE_CODE (TREE_TYPE (exp.value)) != ARRAY_TYPE))
2174 exp.value = convert (build_qualified_type (TREE_TYPE (exp.value),
TYPE_UNQUALIFIED), exp.value);
so the DECL_INITIAL is '(int) i' and not 'i' anymore. Then we don't
suppress_warning here:
711 case DECL_EXPR:
712 /* This is handled mostly by gimplify.cc, but we have to deal with
713 not warning about int x = x; as it is a GCC extension to turn off
714 this warning but only if warn_init_self is zero. */
715 if (VAR_P (DECL_EXPR_DECL (*expr_p))
716 && !DECL_EXTERNAL (DECL_EXPR_DECL (*expr_p))
717 && !TREE_STATIC (DECL_EXPR_DECL (*expr_p))
718 && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL
(*expr_p))
719 && !warn_init_self)
720 suppress_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self);
because of the check on line 718.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12/13 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (5 preceding siblings ...)
2022-07-26 14:09 ` mpolacek at gcc dot gnu.org
@ 2022-07-26 14:28 ` mpolacek at gcc dot gnu.org
2022-07-27 6:11 ` muecker at gwdg dot de
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-07-26 14:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Patch:
--- a/gcc/c-family/c-gimplify.cc
+++ b/gcc/c-family/c-gimplify.cc
@@ -712,13 +712,17 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p
ATTRIBUTE_UNUSED,
/* This is handled mostly by gimplify.cc, but we have to deal with
not warning about int x = x; as it is a GCC extension to turn off
this warning but only if warn_init_self is zero. */
- if (VAR_P (DECL_EXPR_DECL (*expr_p))
- && !DECL_EXTERNAL (DECL_EXPR_DECL (*expr_p))
- && !TREE_STATIC (DECL_EXPR_DECL (*expr_p))
- && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL (*expr_p))
- && !warn_init_self)
- suppress_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self);
- break;
+ {
+ tree &decl = DECL_EXPR_DECL (*expr_p);
+ if (VAR_P (decl)
+ && !DECL_EXTERNAL (decl)
+ && !TREE_STATIC (decl)
+ && (DECL_INITIAL (decl)
+ && tree_strip_nop_conversions (DECL_INITIAL (decl)) == decl)
+ && !warn_init_self)
+ suppress_warning (decl, OPT_Winit_self);
+ break;
+ }
case PREINCREMENT_EXPR:
case PREDECREMENT_EXPR:
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12/13 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (6 preceding siblings ...)
2022-07-26 14:28 ` mpolacek at gcc dot gnu.org
@ 2022-07-27 6:11 ` muecker at gwdg dot de
2022-08-11 14:29 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: muecker at gwdg dot de @ 2022-07-27 6:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
--- Comment #7 from Martin Uecker <muecker at gwdg dot de> ---
Sorry, somehow I missed this. I will look at this once I am back from travel
(if Marek hasen't fixed it)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12/13 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (7 preceding siblings ...)
2022-07-27 6:11 ` muecker at gwdg dot de
@ 2022-08-11 14:29 ` cvs-commit at gcc dot gnu.org
2022-08-11 14:30 ` [Bug middle-end/102633] [11/12 " mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-08-11 14:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:04ce2400b35225302e0d6883bb0817378180f5d7
commit r13-2022-g04ce2400b35225302e0d6883bb0817378180f5d7
Author: Marek Polacek <polacek@redhat.com>
Date: Tue Jul 26 13:55:58 2022 -0400
c-family: Honor -Wno-init-self for cv-qual vars [PR102633]
Since r11-5188-g32934a4f45a721, we drop qualifiers during l-to-r
conversion by creating a NOP_EXPR. For e.g.
const int i = i;
that means that the DECL_INITIAL is '(int) i' and not 'i' anymore.
Consequently, we don't suppress_warning here:
711 case DECL_EXPR:
715 if (VAR_P (DECL_EXPR_DECL (*expr_p))
716 && !DECL_EXTERNAL (DECL_EXPR_DECL (*expr_p))
717 && !TREE_STATIC (DECL_EXPR_DECL (*expr_p))
718 && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL
(*expr_p))
719 && !warn_init_self)
720 suppress_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self);
because of the check on line 718 -- (int) i is not i. So -Wno-init-self
doesn't disable the warning as it's supposed to.
The following patch fixes it by moving the suppress_warning call from
c_gimplify_expr to the front ends, at points where we haven't created
the NOP_EXPR yet.
PR middle-end/102633
gcc/c-family/ChangeLog:
* c-gimplify.cc (c_gimplify_expr) <case DECL_EXPR>: Don't call
suppress_warning here.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_initializer): Add new tree parameter. Use
it.
Call suppress_warning.
(c_parser_declaration_or_fndef): Pass d down to
c_parser_initializer.
(c_parser_omp_declare_reduction): Pass omp_priv down to
c_parser_initializer.
gcc/cp/ChangeLog:
* decl.cc (cp_finish_decl): Call suppress_warning.
gcc/testsuite/ChangeLog:
* c-c++-common/Winit-self1.c: New test.
* c-c++-common/Winit-self2.c: New test.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (8 preceding siblings ...)
2022-08-11 14:29 ` cvs-commit at gcc dot gnu.org
@ 2022-08-11 14:30 ` mpolacek at gcc dot gnu.org
2023-02-10 15:16 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-08-11 14:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Summary|[11/12/13 Regression] |[11/12 Regression] warning
|warning for |for self-initialization
|self-initialization despite |despite -Wno-init-self
|-Wno-init-self |
Status|ASSIGNED |RESOLVED
--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk. Not sure about backporting this.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (9 preceding siblings ...)
2022-08-11 14:30 ` [Bug middle-end/102633] [11/12 " mpolacek at gcc dot gnu.org
@ 2023-02-10 15:16 ` mpolacek at gcc dot gnu.org
2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-02-10 15:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Will try to backport to 12 in order to unblock bug 105593.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (10 preceding siblings ...)
2023-02-10 15:16 ` mpolacek at gcc dot gnu.org
@ 2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
2023-02-10 17:55 ` jakub at gcc dot gnu.org
2023-02-22 16:10 ` [Bug middle-end/102633] [11 " mpolacek at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 17:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:aabebf76e9d9a805ea5b443d4ee4f49f13155d87
commit r12-9160-gaabebf76e9d9a805ea5b443d4ee4f49f13155d87
Author: Marek Polacek <polacek@redhat.com>
Date: Tue Jul 26 13:55:58 2022 -0400
c-family: Honor -Wno-init-self for cv-qual vars [PR102633]
Since r11-5188-g32934a4f45a721, we drop qualifiers during l-to-r
conversion by creating a NOP_EXPR. For e.g.
const int i = i;
that means that the DECL_INITIAL is '(int) i' and not 'i' anymore.
Consequently, we don't suppress_warning here:
711 case DECL_EXPR:
715 if (VAR_P (DECL_EXPR_DECL (*expr_p))
716 && !DECL_EXTERNAL (DECL_EXPR_DECL (*expr_p))
717 && !TREE_STATIC (DECL_EXPR_DECL (*expr_p))
718 && (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL
(*expr_p))
719 && !warn_init_self)
720 suppress_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self);
because of the check on line 718 -- (int) i is not i. So -Wno-init-self
doesn't disable the warning as it's supposed to.
The following patch fixes it by moving the suppress_warning call from
c_gimplify_expr to the front ends, at points where we haven't created
the NOP_EXPR yet.
PR middle-end/102633
gcc/c-family/ChangeLog:
* c-gimplify.cc (c_gimplify_expr) <case DECL_EXPR>: Don't call
suppress_warning here.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_initializer): Add new tree parameter. Use
it.
Call suppress_warning.
(c_parser_declaration_or_fndef): Pass d down to
c_parser_initializer.
(c_parser_omp_declare_reduction): Pass omp_priv down to
c_parser_initializer.
gcc/cp/ChangeLog:
* decl.cc (cp_finish_decl): Call suppress_warning.
gcc/testsuite/ChangeLog:
* c-c++-common/Winit-self1.c: New test.
* c-c++-common/Winit-self2.c: New test.
(cherry picked from commit 04ce2400b35225302e0d6883bb0817378180f5d7)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11/12 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (11 preceding siblings ...)
2023-02-10 17:47 ` cvs-commit at gcc dot gnu.org
@ 2023-02-10 17:55 ` jakub at gcc dot gnu.org
2023-02-22 16:10 ` [Bug middle-end/102633] [11 " mpolacek at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-10 17:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for gcc 12.3 too.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug middle-end/102633] [11 Regression] warning for self-initialization despite -Wno-init-self
2021-10-06 21:40 [Bug middle-end/102633] New: warning for self-initialization despite -Wno-init-self msebor at gcc dot gnu.org
` (12 preceding siblings ...)
2023-02-10 17:55 ` jakub at gcc dot gnu.org
@ 2023-02-22 16:10 ` mpolacek at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-02-22 16:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102633
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |FIXED
--- Comment #13 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
.
^ permalink raw reply [flat|nested] 15+ messages in thread