public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105418] New: debug_tree does not support well for std::construct_at
@ 2022-04-28  9:09 guojiufu at gcc dot gnu.org
  2022-04-28  9:11 ` [Bug c++/105418] " guojiufu at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2022-04-28  9:09 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/105418] debug_tree does not support well for std::construct_at
  2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
@ 2022-04-28  9:11 ` guojiufu at gcc dot gnu.org
  2022-04-28  9:17 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2022-04-28  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

Jiu Fu Guo <guojiufu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5

--- Comment #1 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
Since this just occurs during debugging GCC on the corner case, I put it a low
priority.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/105418] debug_tree does not support well for std::construct_at
  2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
  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
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-28  9:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I wonder if this is because the tree is jot fully constructed yet. Nor the
scope. So this issue might not be a bug.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/105418] debug_tree does not support well for std::construct_at
  2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
  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
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-28  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |trivial

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/105418] debug_tree does not support well for std::construct_at
  2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-28  9:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Debug_tree really only works post frontend in many cases. Especially when
things like overload sets are not resolved and all. You are better just to look
at the contents of the tree itself.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/105418] debug_tree does not support well for std::construct_at
  2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-28  9:20 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-04-28
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |WAITING

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/105418] debug_tree does not support well for std::construct_at
  2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-28 11:04 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
you don't include enough of the backtrace to see where debug_tree comes into
the picture (or decl_as_string FWIW).

Certainly we shouldn't tsubst from debug_tree, so maybe there's something that
can be done in the C++ FE here.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/105418] debug_tree does not support well for std::construct_at
  2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2022-04-29  5:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
0x1089f887 dump_substitution
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/error.cc:1654
0x108a1c2f dump_function_decl
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/error.cc:1817
0x1089e187 dump_decl
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/error.cc:1385
0x108aa8df decl_as_string(tree_node*, int)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/error.cc:3146
0x1094d6ef trees_out::insert(tree_node*, walk_kind)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/module.cc:4801
0x1096300f trees_out::decl_node(tree_node*, walk_kind)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/module.cc:8582
0x10965da3 trees_out::tree_node(tree_node*)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/module.cc:9104
0x109542c7 trees_out::core_vals(tree_node*)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/module.cc:5924
0x10959d4f trees_out::tree_node_vals(tree_node*)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/module.cc:7074
0x10964dab trees_out::tree_value(tree_node*)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/module.cc:8911
0x10965ddf trees_out::tree_node(tree_node*)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/module.cc:9109
0x109542c7 trees_out::core_vals(tree_node*)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/module.cc:5924
0x10959d4f trees_out::tree_node_vals(tree_node*)
        /home/guojiufu/gcc/gcc-mainline-base/gcc/cp/module.cc:7074
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


Hi Andrew and Richard,

Thanks a lot! 
This issue happens when calling debug_tree/decl_as_string manually inside FE. 
At where overloaded functions (::new) are not resolved yet, and then cause
'tsubst' to be called. 
I see, it is not a good place to use debug_tree.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/105418] debug_tree does not support well for std::construct_at
  2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2022-04-29  5:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> ---
(In reply to Jiu Fu Guo from comment #5)
...
> This issue happens when calling debug_tree/decl_as_string manually inside
> FE.  At where overloaded functions (::new) are not resolved yet, and then
> cause 'tsubst' to be called. 
> I see, it is not a good place to use debug_tree.
Or add something in FE for it (not a must :)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/105418] debug_tree does not support well for std::construct_at
  2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-04-29  5:57 ` guojiufu at gcc dot gnu.org
@ 2022-04-29  5:58 ` guojiufu at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: guojiufu at gcc dot gnu.org @ 2022-04-29  5:58 UTC (permalink / raw)
  To: gcc-bugs

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

Jiu Fu Guo <guojiufu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|WAITING                     |RESOLVED

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-04-29  5:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28  9:09 [Bug c++/105418] New: debug_tree does not support well for std::construct_at guojiufu at gcc dot gnu.org
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

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