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

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).