public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105191] New: '<expression>' "is not a constant expression" regression in GCC 12
@ 2022-04-07 3:07 strager.nds at gmail dot com
2022-04-07 11:58 ` [Bug c++/105191] [12 Regression] " ppalka at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: strager.nds at gmail dot com @ 2022-04-07 3:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105191
Bug ID: 105191
Summary: '<expression>' "is not a constant expression"
regression in GCC 12
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: strager.nds at gmail dot com
Target Milestone: ---
Created attachment 52763
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52763&action=edit
C++ source file which demonstrates the issue
Compared to GCC 10 and GCC 11.2, GCC 12 reports an error when compiling my
program. A reduced test case is attached (test.cpp). I think the error is a
false positive; I think my code is valid C++.
g++
(Compiler-Explorer-Build-gcc-d8ac63e4c638a814c2cb7a9f4cebb6606caa4985-binutils-2.36.1)
12.0.1 20220404 (experimental):
g++ (GCC) 12.0.1 20220401 (Red Hat 12.0.1-0):
$ /usr/bin/c++ -std=gnu++11 test.cpp -c
test.cpp:17:5: error: non-constant array initialization
17 | D{},
| ^
test.cpp:18:1: error: call to non-‘constexpr’ function ‘C::C()’
18 | };
| ^
test.cpp:7:8: note: ‘C::C()’ is not usable as a ‘constexpr’ function because:
7 | struct C {
| ^
test.cpp:9:5: note: defaulted default constructor does not initialize ‘B C::b’
9 | B b;
| ^
$ /usr/bin/c++ -std=gnu++20 test.cpp -c
test.cpp:18:1: error: ‘D [1]{D{C [1]{C{A{((const char*)"")}}}}}’ is not a
constant expression
18 | };
| ^
g++-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0:
g++ (Compiler-Explorer-Build-gcc--binutils-2.36.1) 11.2.0:
$ g++-10 -std=gnu++11 test.cpp -c
(no error)
$ g++-10 -std=gnu++20 test.cpp -c
(no error)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/105191] [12 Regression] '<expression>' "is not a constant expression" regression in GCC 12
2022-04-07 3:07 [Bug c++/105191] New: '<expression>' "is not a constant expression" regression in GCC 12 strager.nds at gmail dot com
@ 2022-04-07 11:58 ` ppalka at gcc dot gnu.org
2022-04-07 12:09 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-04-07 11:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105191
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
CC| |jason at gcc dot gnu.org,
| |ppalka at gcc dot gnu.org
Known to work| |10.3.0, 11.2.0
Known to fail| |12.0
Summary|'<expression>' "is not a |[12 Regression]
|constant expression" |'<expression>' "is not a
|regression in GCC 12 |constant expression"
| |regression in GCC 12
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=92385
Last reconfirmed| |2022-04-07
Target Milestone|--- |12.0
Status|UNCONFIRMED |NEW
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, started with r12-6326-ge948436eab818c
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/105191] [12 Regression] '<expression>' "is not a constant expression" regression in GCC 12
2022-04-07 3:07 [Bug c++/105191] New: '<expression>' "is not a constant expression" regression in GCC 12 strager.nds at gmail dot com
2022-04-07 11:58 ` [Bug c++/105191] [12 Regression] " ppalka at gcc dot gnu.org
@ 2022-04-07 12:09 ` jakub at gcc dot gnu.org
2022-04-08 18:53 ` jason at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-07 12:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105191
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Priority|P3 |P1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/105191] [12 Regression] '<expression>' "is not a constant expression" regression in GCC 12
2022-04-07 3:07 [Bug c++/105191] New: '<expression>' "is not a constant expression" regression in GCC 12 strager.nds at gmail dot com
2022-04-07 11:58 ` [Bug c++/105191] [12 Regression] " ppalka at gcc dot gnu.org
2022-04-07 12:09 ` jakub at gcc dot gnu.org
@ 2022-04-08 18:53 ` jason at gcc dot gnu.org
2022-04-09 3:27 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-08 18:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105191
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/105191] [12 Regression] '<expression>' "is not a constant expression" regression in GCC 12
2022-04-07 3:07 [Bug c++/105191] New: '<expression>' "is not a constant expression" regression in GCC 12 strager.nds at gmail dot com
` (2 preceding siblings ...)
2022-04-08 18:53 ` jason at gcc dot gnu.org
@ 2022-04-09 3:27 ` cvs-commit at gcc dot gnu.org
2022-04-09 3:30 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-09 3:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105191
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:4822108e61ab879067482704f2f7d1670813d61a
commit r12-8066-g4822108e61ab879067482704f2f7d1670813d61a
Author: Jason Merrill <jason@redhat.com>
Date: Fri Apr 8 15:33:41 2022 -0400
c++: constexpr non-trivial aggregate init [PR105191]
My patch for PR92385 made us use VEC_INIT_EXPR for aggregate initialization
of an array where some elements are not explicitly initialized. Constexpr
handling of that was treating initialization from {} as equivalent to
value-initialization, which is problematic for classes with default member
initializers that make the default constructor non-trivial; in older
standard modes, not initializing all members makes a constructor
non-constexpr, but aggregate initialization is fine.
PR c++/105191
PR c++/92385
gcc/cp/ChangeLog:
* tree.cc (build_vec_init_elt): Do {}-init for aggregates.
* constexpr.cc (cxx_eval_vec_init): Only treat {} as value-init
for non-aggregate types.
(build_vec_init_expr): Also check constancy of explicit
initializer elements.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/constexpr-array28.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/105191] [12 Regression] '<expression>' "is not a constant expression" regression in GCC 12
2022-04-07 3:07 [Bug c++/105191] New: '<expression>' "is not a constant expression" regression in GCC 12 strager.nds at gmail dot com
` (3 preceding siblings ...)
2022-04-09 3:27 ` cvs-commit at gcc dot gnu.org
@ 2022-04-09 3:30 ` jason at gcc dot gnu.org
2022-05-15 16:28 ` cvs-commit at gcc dot gnu.org
2022-05-15 16:29 ` cvs-commit at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-09 3:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105191
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/105191] [12 Regression] '<expression>' "is not a constant expression" regression in GCC 12
2022-04-07 3:07 [Bug c++/105191] New: '<expression>' "is not a constant expression" regression in GCC 12 strager.nds at gmail dot com
` (4 preceding siblings ...)
2022-04-09 3:30 ` jason at gcc dot gnu.org
@ 2022-05-15 16:28 ` cvs-commit at gcc dot gnu.org
2022-05-15 16:29 ` cvs-commit at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-15 16:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105191
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:ce46d6041358052dfa26f3720732f0357c5d72e7
commit r13-463-gce46d6041358052dfa26f3720732f0357c5d72e7
Author: Jason Merrill <jason@redhat.com>
Date: Fri May 13 16:07:10 2022 -0400
c++: array {}-init [PR105589]
My patch for 105191 made us use build_value_init more frequently from
build_vec_init_expr, but build_value_init doesn't like to be called to
initialize a class in a template. That's caused trouble in the past, and
seems like a strange restriction, so let's fix it.
PR c++/105589
PR c++/105191
PR c++/92385
gcc/cp/ChangeLog:
* init.cc (build_value_init): Handle class in template.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-array16.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/105191] [12 Regression] '<expression>' "is not a constant expression" regression in GCC 12
2022-04-07 3:07 [Bug c++/105191] New: '<expression>' "is not a constant expression" regression in GCC 12 strager.nds at gmail dot com
` (5 preceding siblings ...)
2022-05-15 16:28 ` cvs-commit at gcc dot gnu.org
@ 2022-05-15 16:29 ` cvs-commit at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-05-15 16:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105191
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:
https://gcc.gnu.org/g:40f749b364b740f41ea6b211f81c21919a2e8bee
commit r12-8380-g40f749b364b740f41ea6b211f81c21919a2e8bee
Author: Jason Merrill <jason@redhat.com>
Date: Fri May 13 16:07:10 2022 -0400
c++: array {}-init [PR105589]
My patch for 105191 made us use build_value_init more frequently from
build_vec_init_expr, but build_value_init doesn't like to be called to
initialize a class in a template. That's caused trouble in the past, and
seems like a strange restriction, so let's fix it.
PR c++/105589
PR c++/105191
PR c++/92385
gcc/cp/ChangeLog:
* init.cc (build_value_init): Handle class in template.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-array16.C: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-05-15 16:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 3:07 [Bug c++/105191] New: '<expression>' "is not a constant expression" regression in GCC 12 strager.nds at gmail dot com
2022-04-07 11:58 ` [Bug c++/105191] [12 Regression] " ppalka at gcc dot gnu.org
2022-04-07 12:09 ` jakub at gcc dot gnu.org
2022-04-08 18:53 ` jason at gcc dot gnu.org
2022-04-09 3:27 ` cvs-commit at gcc dot gnu.org
2022-04-09 3:30 ` jason at gcc dot gnu.org
2022-05-15 16:28 ` cvs-commit at gcc dot gnu.org
2022-05-15 16:29 ` cvs-commit at gcc dot gnu.org
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).