public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102626] New: [c++20] compiler crash when invoking constexpr function in the constructor of template class
@ 2021-10-06 6:41 royalbee at gmail dot com
2021-10-11 8:31 ` [Bug c++/102626] " marxin at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: royalbee at gmail dot com @ 2021-10-06 6:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102626
Bug ID: 102626
Summary: [c++20] compiler crash when invoking constexpr
function in the constructor of template class
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: royalbee at gmail dot com
Target Milestone: ---
* version: g++ (Compiler-Explorer-Build-gcc--binutils-2.36.1) 11.2.0
* compile options: -std=c++20 -O3
* online example: https://godbolt.org/z/hz61so9vc
* compiling produces error:
during RTL pass: expand
<source>: In function 'int main()':
<source>:15:50: internal compiler error: Segmentation fault
15 | auto p = packed<A, &A::x, &A::y>{std::span(buf)};
| ^
0x1786229 internal_error(char const*, ...)
???:0
0xff757b make_decl_rtl(tree_node*)
???:0
0x8f9536 expand_call(tree_node*, rtx_def*, int)
???:0
0xa0ff2e expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
ASM generation compiler returned: 1
during RTL pass: expand
<source>: In function 'int main()':
<source>:15:50: internal compiler error: Segmentation fault
15 | auto p = packed<A, &A::x, &A::y>{std::span(buf)};
| ^
0x1786229 internal_error(char const*, ...)
???:0
0xff757b make_decl_rtl(tree_node*)
???:0
0x8f9536 expand_call(tree_node*, rtx_def*, int)
???:0
0xa0ff2e expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Execution build compiler returned: 1
* code:
#include <span>
template <typename T, auto ...ms> struct packed;
template <typename S, typename ...Ts, Ts S::* ...ms>
struct packed<S, ms...> {
static constexpr size_t size() { return (sizeof(S{}.*ms) + ...); }
std::span<std::byte> buf;
packed(auto b) : buf(b.first(size())) {} //<<< removing call to size() fixes
the issue
};
int main() {
struct A {int x, y;};
std::byte buf[100];
auto p = packed<A, &A::x, &A::y>{std::span(buf)};
static_assert(p.size() == 8);
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/102626] [c++20] compiler crash when invoking constexpr function in the constructor of template class
2021-10-06 6:41 [Bug c++/102626] New: [c++20] compiler crash when invoking constexpr function in the constructor of template class royalbee at gmail dot com
@ 2021-10-11 8:31 ` marxin at gcc dot gnu.org
2021-10-11 8:40 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-11 8:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102626
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-10-11
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |marxin at gcc dot gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/102626] [c++20] compiler crash when invoking constexpr function in the constructor of template class
2021-10-06 6:41 [Bug c++/102626] New: [c++20] compiler crash when invoking constexpr function in the constructor of template class royalbee at gmail dot com
2021-10-11 8:31 ` [Bug c++/102626] " marxin at gcc dot gnu.org
@ 2021-10-11 8:40 ` jakub at gcc dot gnu.org
2021-10-11 9:50 ` marxin at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-10-11 8:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102626
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly reduced:
template <typename T, auto ...ms> struct P;
template <typename S, typename ...Ts, Ts S::* ...ms>
struct P<S, ms...> {
static constexpr int size() { return (sizeof(S{}.*ms) + ...); }
int sz;
P() : sz(size()) {}
};
struct A { int x, y; };
auto p = P<A, &A::x, &A::y>();
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/102626] [c++20] compiler crash when invoking constexpr function in the constructor of template class
2021-10-06 6:41 [Bug c++/102626] New: [c++20] compiler crash when invoking constexpr function in the constructor of template class royalbee at gmail dot com
2021-10-11 8:31 ` [Bug c++/102626] " marxin at gcc dot gnu.org
2021-10-11 8:40 ` jakub at gcc dot gnu.org
@ 2021-10-11 9:50 ` marxin at gcc dot gnu.org
2024-01-22 16:09 ` hp at gcc dot gnu.org
2024-01-22 17:10 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-11 9:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102626
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with introduction of -std=c++2a (r8-3237-g026a79f70cf33f83).
Btw. clang accepts the code, so like ice-on-valid-code.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/102626] [c++20] compiler crash when invoking constexpr function in the constructor of template class
2021-10-06 6:41 [Bug c++/102626] New: [c++20] compiler crash when invoking constexpr function in the constructor of template class royalbee at gmail dot com
` (2 preceding siblings ...)
2021-10-11 9:50 ` marxin at gcc dot gnu.org
@ 2024-01-22 16:09 ` hp at gcc dot gnu.org
2024-01-22 17:10 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: hp at gcc dot gnu.org @ 2024-01-22 16:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102626
Hans-Peter Nilsson <hp at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hp at gcc dot gnu.org
Last reconfirmed|2021-10-11 00:00:00 |2024-01-14 0:00
--- Comment #4 from Hans-Peter Nilsson <hp at gcc dot gnu.org> ---
Searching for a constexpr-related bug (not this one) I can confirm that (for
cris-elf at least) the bug is still there at r14-7232-gb468821eea8d
(the test-case in comment #2 with "-std=c++20 -O3")
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/102626] [c++20] compiler crash when invoking constexpr function in the constructor of template class
2021-10-06 6:41 [Bug c++/102626] New: [c++20] compiler crash when invoking constexpr function in the constructor of template class royalbee at gmail dot com
` (3 preceding siblings ...)
2024-01-22 16:09 ` hp at gcc dot gnu.org
@ 2024-01-22 17:10 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-01-22 17:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102626
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=86933,
| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=92969
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
PR86933, PR92969 and this all seem related. GCC seems to mishandle a type
template parameter pack appearing in the return type of a pointer to data
member NTTP pack:
typename ...Ts, Ts S::* ...ms
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-01-22 17:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 6:41 [Bug c++/102626] New: [c++20] compiler crash when invoking constexpr function in the constructor of template class royalbee at gmail dot com
2021-10-11 8:31 ` [Bug c++/102626] " marxin at gcc dot gnu.org
2021-10-11 8:40 ` jakub at gcc dot gnu.org
2021-10-11 9:50 ` marxin at gcc dot gnu.org
2024-01-22 16:09 ` hp at gcc dot gnu.org
2024-01-22 17:10 ` ppalka 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).