* [Bug c++/116418] [12/13/14/15 Regression] Nested statement expressions with decltype auto in template break
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
@ 2024-08-19 16:10 ` pinskia at gcc dot gnu.org
2024-08-20 7:36 ` rguenth at gcc dot gnu.org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-19 16:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |12.5
Summary|[11/12/13/14/15 Regression] |[12/13/14/15 Regression]
|Nested statement |Nested statement
|expressions with decltype |expressions with decltype
|auto in template break |auto in template break
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] Nested statement expressions with decltype auto in template break
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
2024-08-19 16:10 ` [Bug c++/116418] [12/13/14/15 " pinskia at gcc dot gnu.org
@ 2024-08-20 7:36 ` rguenth at gcc dot gnu.org
2024-08-20 13:54 ` valentin at tolmer dot fr
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-08-20 7:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |WAITING
Ever confirmed|0 |1
Last reconfirmed| |2024-08-20
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The testcase isn't complete, fn() isn't instantiated so I can't reproduce the
issue. Adding
void bar()
{
fn<int>();
}
doesn't make it fail with GCC 11.1 for me.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] Nested statement expressions with decltype auto in template break
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
2024-08-19 16:10 ` [Bug c++/116418] [12/13/14/15 " pinskia at gcc dot gnu.org
2024-08-20 7:36 ` rguenth at gcc dot gnu.org
@ 2024-08-20 13:54 ` valentin at tolmer dot fr
2024-08-20 17:21 ` [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on pinskia at gcc dot gnu.org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: valentin at tolmer dot fr @ 2024-08-20 13:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
--- Comment #2 from Valentin Tolmer <valentin at tolmer dot fr> ---
Sorry, typo in the last sentence: "the templated function doesn't have to be
instantiated to trigger the bug".
See https://godbolt.org/z/3xosx5dn4 for a reproduction.
Adding an instantiation gives an additional knock-on error:
<source>: In instantiation of 'void fn() [with <template-parameter-1-1> =
int]':
<source>:10:12: required from here
<source>:3:21: error: variable or field 'v' declared void
3 | ({ decltype(auto) v = ({3;});}); // breaks
| ^
Richard, are you sure you compiled with -O1?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (2 preceding siblings ...)
2024-08-20 13:54 ` valentin at tolmer dot fr
@ 2024-08-20 17:21 ` pinskia at gcc dot gnu.org
2024-09-03 15:57 ` jakub at gcc dot gnu.org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-20 17:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |55004
Summary|[12/13/14/15 Regression] |[12/13/14/15 Regression]
|Nested statement |statement expressions as
|expressions with decltype |initializer for decltype
|auto in template break |auto breaks in templates
| |with optimization turned on
Status|WAITING |NEW
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
Reduced testcase:
```
template <typename>
void fn() {
decltype(auto) v = ({3;}); // breaks
}
```
Fails at -O1+. Most likely a check for optimization in the front-end trying to
optimize the initializer and using the const expression path for that.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55004
[Bug 55004] [meta-bug] constexpr issues
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (3 preceding siblings ...)
2024-08-20 17:21 ` [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on pinskia at gcc dot gnu.org
@ 2024-09-03 15:57 ` jakub at gcc dot gnu.org
2024-09-03 15:59 ` [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info " pinskia at gcc dot gnu.org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-09-03 15:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Can't reproduce either, tried GCC 11, 12, 13, 14, trunk, -O1 -std=c++20 or -O1
-std=c++23.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (4 preceding siblings ...)
2024-09-03 15:57 ` jakub at gcc dot gnu.org
@ 2024-09-03 15:59 ` pinskia at gcc dot gnu.org
2024-09-03 16:03 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-03 15:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[12/13/14/15 Regression] |[12/13/14/15 Regression]
|statement expressions as |statement expressions as
|initializer for decltype |initializer for decltype
|auto breaks in templates |auto breaks in templates
|with optimization turned on |with optimization turned on
| |and debug info turned on
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #4)
> Can't reproduce either, tried GCC 11, 12, 13, 14, trunk, -O1 -std=c++20 or
> -O1 -std=c++23.
Oh it is with -g too.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (5 preceding siblings ...)
2024-09-03 15:59 ` [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info " pinskia at gcc dot gnu.org
@ 2024-09-03 16:03 ` pinskia at gcc dot gnu.org
2024-09-03 16:08 ` [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on due to gstatement-frontiers jakub at gcc dot gnu.org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-03 16:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #5)
> (In reply to Jakub Jelinek from comment #4)
> > Can't reproduce either, tried GCC 11, 12, 13, 14, trunk, -O1 -std=c++20 or
> > -O1 -std=c++23.
>
> Oh it is with -g too.
`-gno-statement-frontiers ` fixes the issue.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on due to gstatement-frontiers
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (6 preceding siblings ...)
2024-09-03 16:03 ` pinskia at gcc dot gnu.org
@ 2024-09-03 16:08 ` jakub at gcc dot gnu.org
2024-09-03 16:08 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-09-03 16:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Ah, with -g -O1 -std=c++20 it started with
r11-7452-g04b10596fe2fec1aa6652c15fd389087a78a235f
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on due to gstatement-frontiers
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (7 preceding siblings ...)
2024-09-03 16:08 ` [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on due to gstatement-frontiers jakub at gcc dot gnu.org
@ 2024-09-03 16:08 ` jakub at gcc dot gnu.org
2024-09-03 16:18 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-09-03 16:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on due to gstatement-frontiers
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (8 preceding siblings ...)
2024-09-03 16:08 ` jakub at gcc dot gnu.org
@ 2024-09-03 16:18 ` jakub at gcc dot gnu.org
2024-09-11 0:39 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-09-03 16:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
void foo ();
template <typename>
void bar ()
{
decltype(auto) v = ({ foo (); 3; });
}
doesn't need -O1 nor -g to trigger the error, and can be reproduced with
-std=c++14 and higher. Still started with that commit, before that it has been
accepted.
strip_typedefs_expr errors on STATEMENT_LIST, which is called by the
canonicalize_type_argument call which has been added in that change.
I think decltype(auto) deduction shouldn't require a constant expression in the
initializer.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on due to gstatement-frontiers
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (9 preceding siblings ...)
2024-09-03 16:18 ` jakub at gcc dot gnu.org
@ 2024-09-11 0:39 ` ppalka at gcc dot gnu.org
2024-09-12 16:45 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-09-11 0:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on due to gstatement-frontiers
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (10 preceding siblings ...)
2024-09-11 0:39 ` ppalka at gcc dot gnu.org
@ 2024-09-12 16:45 ` cvs-commit at gcc dot gnu.org
2024-09-20 22:10 ` cvs-commit at gcc dot gnu.org
2024-09-20 22:10 ` [Bug c++/116418] [12/13 " ppalka at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-09-12 16:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:12bdcc3d7970860b9d66ed4dea203bde8fd68d4d
commit r15-3611-g12bdcc3d7970860b9d66ed4dea203bde8fd68d4d
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Sep 12 12:45:03 2024 -0400
c++: decltype(auto) deduction of statement-expression [PR116418]
r8-7538 for PR84968 made strip_typedefs_expr diagnose STATEMENT_LIST
so that we reject statement-expressions in noexcept-specifiers to
match our behavior in template arguments (which the parser diagnoses
directly).
Later r11-7452 made decltype(auto) deduction canonicalize the expression
(as an implementation detail) which in turn calls strip_typedefs_expr,
and so ever since we inadvertently reject decltype(auto) deduction of a
statement-expression.
This patch just removes the diagnostic in strip_typedefs_expr and instead
treats statement-expressions similar to lambda-expressions. The function
doesn't seem like the right place for such a diagnostic and so it seems
easier to just accept rather than try to reject them in a suitable place.
PR c++/116418
gcc/cp/ChangeLog:
* tree.cc (strip_typedefs_expr) <case STATEMENT_LIST>: Replace
this error path with ...
<case STMT_EXPR>: ... this, returning the original tree.
gcc/testsuite/ChangeLog:
* g++.dg/eh/pr84968.C: No longer expect an ahead of time diagnostic
for the statement-expresssion. Instantiate the template and expect
an incomplete type error instead.
* g++.dg/ext/stmtexpr26.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13/14/15 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on due to gstatement-frontiers
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (11 preceding siblings ...)
2024-09-12 16:45 ` cvs-commit at gcc dot gnu.org
@ 2024-09-20 22:10 ` cvs-commit at gcc dot gnu.org
2024-09-20 22:10 ` [Bug c++/116418] [12/13 " ppalka at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-09-20 22:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:abdea396e12e66185d810435bbc363845cf4664a
commit r14-10697-gabdea396e12e66185d810435bbc363845cf4664a
Author: Patrick Palka <ppalka@redhat.com>
Date: Thu Sep 12 12:45:03 2024 -0400
c++: decltype(auto) deduction of statement-expression [PR116418]
r8-7538 for PR84968 made strip_typedefs_expr diagnose STATEMENT_LIST
so that we reject statement-expressions in noexcept-specifiers to
match our behavior in template arguments (which the parser diagnoses
directly).
Later r11-7452 made decltype(auto) deduction canonicalize the expression
(as an implementation detail) which in turn calls strip_typedefs_expr,
and so ever since we inadvertently reject decltype(auto) deduction of a
statement-expression.
This patch just removes the diagnostic in strip_typedefs_expr and instead
treats statement-expressions similar to lambda-expressions. The function
doesn't seem like the right place for such a diagnostic and so it seems
easier to just accept rather than try to reject them in a suitable place.
PR c++/116418
gcc/cp/ChangeLog:
* tree.cc (strip_typedefs_expr) <case STATEMENT_LIST>: Replace
this error path with ...
<case STMT_EXPR>: ... this, returning the original tree.
gcc/testsuite/ChangeLog:
* g++.dg/eh/pr84968.C: No longer expect an ahead of time diagnostic
for the statement-expresssion. Instantiate the template and expect
an incomplete type error instead.
* g++.dg/ext/stmtexpr26.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
(cherry picked from commit 12bdcc3d7970860b9d66ed4dea203bde8fd68d4d)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/116418] [12/13 Regression] statement expressions as initializer for decltype auto breaks in templates with optimization turned on and debug info turned on due to gstatement-frontiers
2024-08-19 15:58 [Bug c++/116418] New: [11/12/13/14/15 Regression] Nested statement expressions with decltype auto in template break valentin at tolmer dot fr
` (12 preceding siblings ...)
2024-09-20 22:10 ` cvs-commit at gcc dot gnu.org
@ 2024-09-20 22:10 ` ppalka at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-09-20 22:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116418
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[12/13/14/15 Regression] |[12/13 Regression]
|statement expressions as |statement expressions as
|initializer for decltype |initializer for decltype
|auto breaks in templates |auto breaks in templates
|with optimization turned on |with optimization turned on
|and debug info turned on |and debug info turned on
|due to gstatement-frontiers |due to gstatement-frontiers
--- Comment #11 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14.3 so far.
^ permalink raw reply [flat|nested] 15+ messages in thread