public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "guojiufu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/105418] New: debug_tree does not support well for std::construct_at
Date: Thu, 28 Apr 2022 09:09:07 +0000	[thread overview]
Message-ID: <bug-105418-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105418

            Bug ID: 105418
           Summary: debug_tree does not support well for std::construct_at
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: guojiufu at gcc dot gnu.org
  Target Milestone: ---

During debug GCC, when call "debug_tree" inside gdb, I found "debug_tree" fail
on "std::construct_at". It fails from "decl_as_string"

To reproduce this issue quicker, the below patch could be used. 
-----------
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index cebf9c35c1d..ead4112dd37 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -4793,10 +4793,12 @@ trees_out::get_tag (tree t)
 }

 /* Insert T into the map, return its tag number.    */
-
+const char* decl_as_string(tree, int);//void debug_tree(tree);
 int
 trees_out::insert (tree t, walk_kind walk)
 {
+  if (TREE_CODE (t) == FUNCTION_DECL)
+    decl_as_string (t,TFF_DECL_SPECIFIERS);//debug_tree (t);
   gcc_checking_assert (walk != WK_normal || !TREE_VISITED (t));
   int tag = --ref_num;
   bool existed;
----------
configure the GCC with below command:
$ configure --enable-languages=c,c++ --with-cpu=native --enable-checking
--with-long-double-128
--prefix=/home/guojiufu/gcc/install/gcc-mainline-base-debug --disable-bootstrap

Using test case: t.cc
-----------
#include <memory>

struct S {
    int x;
    float y;
    double z;

    S(int x, float y, double z) : x{x}, y{y}, z{z} { }

};

void foo()
{
    alignas(S) unsigned char storage[sizeof(S)];

    S* ptr = std::construct_at(reinterpret_cast<S*>(storage), 42, 2.71828f,
3.1415);

    std::destroy_at(ptr);
}

------------
$ g++ -fmodule-header t.cc -std=gnu++20
In file included from
/home/guojiufu/gcc/build/gcc-mainline-base-debug/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/stl_iterator.h:85,
                 from
/home/guojiufu/gcc/build/gcc-mainline-base-debug/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/stl_algobase.h:67,
                 from
/home/guojiufu/gcc/build/gcc-mainline-base-debug/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/memory:63,
                 from t.cc:1:
/home/guojiufu/gcc/build/gcc-mainline-base-debug/powerpc64le-unknown-linux-gnu/libstdc++-v3/include/bits/stl_construct.h:96:17:
internal compiler error: in perform_overload_resolution, at cp/call.cc:4710
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x106b32cb perform_overload_resolution
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/call.cc:4710
0x106b3d9f build_operator_new_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node**, tree_node**, tree_node*, tree_node*, tree_node**,
int)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/call.cc:4929
0x108d0743 build_new_1
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/init.cc:3412
0x108d300f build_new(unsigned int, vec<tree_node*, va_gc, vl_embed>**,
tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int, int)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/init.cc:4014
0x10b210ef tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/pt.cc:20557
0x10b01ddf tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/pt.cc:16306
0x10896f6b dump_template_bindings
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/error.cc:486
0x1089f887 dump_substitution
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/error.cc:1654

             reply	other threads:[~2022-04-28  9:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28  9:09 guojiufu at gcc dot gnu.org [this message]
2022-04-28  9:11 ` [Bug c++/105418] " guojiufu at gcc dot gnu.org
2022-04-28  9:17 ` pinskia at gcc dot gnu.org
2022-04-28  9:18 ` pinskia at gcc dot gnu.org
2022-04-28  9:20 ` pinskia at gcc dot gnu.org
2022-04-28  9:20 ` pinskia at gcc dot gnu.org
2022-04-28 11:04 ` rguenth at gcc dot gnu.org
2022-04-29  5:32 ` guojiufu at gcc dot gnu.org
2022-04-29  5:57 ` guojiufu at gcc dot gnu.org
2022-04-29  5:58 ` guojiufu at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105418-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).