* [Bug c++/115913] ICE with pragma GCC pop_options (‘global_options’ are modified in local context)
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
@ 2024-07-14 2:15 ` sjames at gcc dot gnu.org
2024-07-14 2:18 ` sjames at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-07-14 2:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
--- Comment #1 from Sam James <sjames at gcc dot gnu.org> ---
It was fine until I moved the push_options+optimize above the include block.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/115913] ICE with pragma GCC pop_options (‘global_options’ are modified in local context)
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
2024-07-14 2:15 ` [Bug c++/115913] " sjames at gcc dot gnu.org
@ 2024-07-14 2:18 ` sjames at gcc dot gnu.org
2024-07-14 2:26 ` [Bug middle-end/115913] " pinskia at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-07-14 2:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
Surrounding hb.hh does it, which makes sense given how much pragma fun it does:
https://github.com/harfbuzz/harfbuzz/blob/main/src/hb.hh.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115913] ICE with pragma GCC pop_options (‘global_options’ are modified in local context)
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
2024-07-14 2:15 ` [Bug c++/115913] " sjames at gcc dot gnu.org
2024-07-14 2:18 ` sjames at gcc dot gnu.org
@ 2024-07-14 2:26 ` pinskia at gcc dot gnu.org
2024-07-14 3:50 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-14 2:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c++ |middle-end
Target| |x86_64
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This might be a target issue or a middle-end issue. Doubt it is a C++ front-end
issue.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115913] ICE with pragma GCC pop_options (‘global_options’ are modified in local context)
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
` (2 preceding siblings ...)
2024-07-14 2:26 ` [Bug middle-end/115913] " pinskia at gcc dot gnu.org
@ 2024-07-14 3:50 ` pinskia at gcc dot gnu.org
2024-07-14 3:54 ` [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic pinskia at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-14 3:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
```
#pragma GCC push_options
#pragma GCC diagnostic warning "-Wundef"
#pragma GCC pop_options
```
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
` (3 preceding siblings ...)
2024-07-14 3:50 ` pinskia at gcc dot gnu.org
@ 2024-07-14 3:54 ` pinskia at gcc dot gnu.org
2024-07-14 3:54 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-14 3:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |10.1.0, 10.5.0
Summary|ICE with pragma GCC |[11/12/13/14/15 Regression]
|pop_options |ICE with pragma GCC
|(‘global_options’ are |pop_options with diagnostic
|modified in local context) |
Target Milestone|--- |15.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
` (4 preceding siblings ...)
2024-07-14 3:54 ` [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic pinskia at gcc dot gnu.org
@ 2024-07-14 3:54 ` pinskia at gcc dot gnu.org
2024-07-15 8:34 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-14 3:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-07-14
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
confirmed.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
` (5 preceding siblings ...)
2024-07-14 3:54 ` pinskia at gcc dot gnu.org
@ 2024-07-15 8:34 ` rguenth at gcc dot gnu.org
2024-07-18 21:47 ` [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic since r11-1141 lhyatt at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-07-15 8:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|15.0 |11.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic since r11-1141
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
` (6 preceding siblings ...)
2024-07-15 8:34 ` rguenth at gcc dot gnu.org
@ 2024-07-18 21:47 ` lhyatt at gcc dot gnu.org
2024-07-18 21:56 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2024-07-18 21:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
Lewis Hyatt <lhyatt at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lhyatt at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
Summary|[11/12/13/14/15 Regression] |[11/12/13/14/15 Regression]
|ICE with pragma GCC |ICE with pragma GCC
|pop_options with diagnostic |pop_options with diagnostic
| |since r11-1141
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=92860
--- Comment #6 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
Started with r11-1141 (which added the checking assert in the first place). I
think this check is ensuring that after this sequence:
#pragma GCC push_options
#pragma GCC optimize ...
#pragma GCC pop_options
all the options have been restored to their previous values. But it doesn't
consider that the options might have been deliberately changed by another
pragma, in which case they are not expected to retain their previous values.
I think the fix in the spirit of this check is to disable the check while a
diagnostic pragma is in force. This untested patch resolves it that way, if the
approach seems reasonable I could prepare it?
diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc
index 25251c2b69f..0080bac99bf 100644
--- a/gcc/c-family/c-pragma.cc
+++ b/gcc/c-family/c-pragma.cc
@@ -866,6 +866,9 @@ pragma_diagnostic_lex (pragma_diagnostic_data *result)
result->valid = true;
}
+static void
+options_stack_disable_checking ();
+
/* Handle #pragma GCC diagnostic. Early mode is used by frontends (such as
C++)
that do not process the deferred pragma while they are consuming tokens;
they
can use early mode to make sure diagnostics affecting the preprocessor
itself
@@ -1020,6 +1023,7 @@ handle_pragma_diagnostic_impl ()
input_location, lang_mask, &handlers,
&global_options, &global_options_set,
global_dc);
+ options_stack_disable_checking ();
}
static void
@@ -1192,10 +1196,18 @@ struct GTY(()) opt_stack {
tree optimize_binary;
tree optimize_strings;
gcc_options * GTY ((skip)) saved_global_options;
+ bool disable_checking;
};
static GTY(()) struct opt_stack * options_stack;
+static void
+options_stack_disable_checking ()
+{
+ if (options_stack)
+ options_stack->disable_checking = true;
+}
+
/* Handle #pragma GCC push_options to save the current target and optimization
options. */
@@ -1212,7 +1224,7 @@ handle_pragma_push_options (cpp_reader *)
return;
}
- opt_stack *p = ggc_alloc<opt_stack> ();
+ opt_stack *p = ggc_cleared_alloc<opt_stack> ();
p->prev = options_stack;
options_stack = p;
@@ -1260,6 +1272,14 @@ handle_pragma_pop_options (cpp_reader *)
p = options_stack;
options_stack = p->prev;
+ if (flag_checking && p->disable_checking)
+ {
+ XDELETEVEC (p->saved_global_options);
+ p->saved_global_options = nullptr;
+ if (p->prev)
+ p->prev->disable_checking = true;
+ }
+
if (p->target_binary != target_option_current_node)
{
(void) targetm.target_option.pragma_parse (NULL_TREE, p->target_binary);
@@ -1279,7 +1299,7 @@ handle_pragma_pop_options (cpp_reader *)
p->optimize_binary);
optimization_current_node = p->optimize_binary;
}
- if (flag_checking && !seen_error ())
+ if (flag_checking && p->saved_global_options && !seen_error ())
{
cl_optimization_compare (p->saved_global_options, &global_options);
free (p->saved_global_options);
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic since r11-1141
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
` (7 preceding siblings ...)
2024-07-18 21:47 ` [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic since r11-1141 lhyatt at gcc dot gnu.org
@ 2024-07-18 21:56 ` pinskia at gcc dot gnu.org
2024-07-18 22:07 ` lhyatt at gcc dot gnu.org
2024-07-19 13:26 ` [Bug middle-end/115913] [12/13/14/15 " rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-07-18 21:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The bigger question should `GCC pop_options` also pop the diagnostic option
changes too? or is that only done with `GCC diagnostic pop`.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115913] [11/12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic since r11-1141
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
` (8 preceding siblings ...)
2024-07-18 21:56 ` pinskia at gcc dot gnu.org
@ 2024-07-18 22:07 ` lhyatt at gcc dot gnu.org
2024-07-19 13:26 ` [Bug middle-end/115913] [12/13/14/15 " rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: lhyatt at gcc dot gnu.org @ 2024-07-18 22:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
--- Comment #8 from Lewis Hyatt <lhyatt at gcc dot gnu.org> ---
I think they are for different things, push_options/pop_options is for saving
and restoring the command line flags that get implied from switching
optimization levels or target pragmas, while diagnostic pragmas are for turning
and and off warnings flags. So I guess another alternative to the patch I
posted would be, #pragma GCC pop_options could ignore all warnings-related
options when doing its checking? I'm not sure if it was intentional that it
wanted to check those or not.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/115913] [12/13/14/15 Regression] ICE with pragma GCC pop_options with diagnostic since r11-1141
2024-07-14 2:14 [Bug c++/115913] New: ICE with pragma GCC pop_options (‘global_options’ are modified in local context) sjames at gcc dot gnu.org
` (9 preceding siblings ...)
2024-07-18 22:07 ` lhyatt at gcc dot gnu.org
@ 2024-07-19 13:26 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-07-19 13:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115913
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.5 |12.5
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11 branch is being closed.
^ permalink raw reply [flat|nested] 12+ messages in thread