public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "jwakely.gcc at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/28480] pretty printing getting confused
Date: Thu, 04 Nov 2021 16:52:52 +0000	[thread overview]
Message-ID: <bug-28480-4717-QkOA9LRHP0@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28480-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28480

--- Comment #8 from Jonathan Wakely <jwakely.gcc at gmail dot com> ---
Standalone reproducer:

namespace std
{
#if __has_cpp_attribute(__no_unique_address__)
#warning using attr
  template<typename T>
    struct _Head_base
    {
      [[__no_unique_address__]] T _M_head_impl;
    };
#else
#warning not using attr
  template<typename T>
    struct _Head_base : T
    { };
#endif

  template<typename T>
    struct _Head_base<T*>
    {
      T* _M_head_impl;
    };

  template<unsigned long, typename ...> struct _Tuple_impl;

  template<typename T, typename U>
    struct _Tuple_impl<0, T, U> : _Tuple_impl<1, U>, _Head_base<T>
    { };

  template<typename U>
    struct _Tuple_impl<1, U> : _Head_base<U>
    { };

  template<typename T, typename U>
    struct tuple : _Tuple_impl<0, T, U>
    { };

  template<typename T> struct default_delete { };

  template<typename T, typename D = default_delete<T>>
    struct unique_ptr
    {
      unique_ptr(T* p) { _M_t._Head_base<T*>::_M_head_impl = p; }

      using __tuple_type = tuple<T*, D>;

      __tuple_type _M_t;
    };
}

struct datum
{
  const char* s;
  int i;
};

int
main()
{
  std::unique_ptr<datum> uptr (new datum);
  return 0;
}

compiled with GCC 9 or above this uses the [[no_unique_address]] attribute, an
GDB gets confused:

$ GCC 8 up.C -Wno-unused && ~/gcc/gdb/11/bin/gdb -q  -ex 'start' -ex n -ex  'p
uptr' a.out
up.C:11:2: warning: #warning not using attr [-Wcpp]
 #warning not using attr
  ^~~~~~~
Reading symbols from a.out...
Temporary breakpoint 1 at 0x40112a: file up.C, line 59.
Starting program: /tmp/a.out 

Temporary breakpoint 1, main () at up.C:59
59        std::unique_ptr<datum> uptr (new datum);
60        return 0;
$1 = std::unique_ptr<datum> = {get() = 0x416eb0}


$ GCC 9 up.C -Wno-unused && ~/gcc/gdb/11/bin/gdb -q  -ex 'start' -ex n -ex  'p
uptr' a.out
up.C:4:2: warning: #warning using attr [-Wcpp]
    4 | #warning using attr
      |  ^~~~~~~
Reading symbols from a.out...
Temporary breakpoint 1 at 0x40112a: file up.C, line 59.
Starting program: /tmp/a.out 

Temporary breakpoint 1, main () at up.C:59
59        std::unique_ptr<datum> uptr (new datum);
60        return 0;
$1 = std::unique_ptr<datum> = {get() = {<No data fields>}}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2021-11-04 16:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-20 22:43 [Bug gdb/28480] New: " jwakely.gcc at gmail dot com
2021-10-21  0:44 ` [Bug gdb/28480] " jwakely.gcc at gmail dot com
2021-10-21  0:49 ` jwakely.gcc at gmail dot com
2021-10-21  0:56 ` jwakely.gcc at gmail dot com
2021-10-21  3:23 ` simark at simark dot ca
2021-10-21  8:44 ` jwakely.gcc at gmail dot com
2021-10-26 19:14 ` blarsen at redhat dot com
2021-11-04 16:01 ` blarsen at redhat dot com
2021-11-04 16:52 ` jwakely.gcc at gmail dot com [this message]
2021-11-04 17:06 ` jwakely.gcc at gmail dot com
2021-11-04 17:09 ` jwakely.gcc at gmail dot com
2021-11-04 17:36 ` jwakely.gcc at gmail dot com
2021-11-04 17:42 ` jwakely.gcc at gmail dot com
2021-11-04 17:53 ` jwakely.gcc at gmail dot com
2021-11-04 17:56 ` simark at simark dot ca
2021-11-04 17:59 ` simark at simark dot ca
2021-11-04 18:07 ` blarsen at redhat dot com
2021-11-04 18:45 ` pedro at palves dot net
2021-11-04 19:40 ` blarsen at redhat dot com
2021-11-05 13:53 ` blarsen at redhat dot com
2021-11-05 14:29 ` [Bug c++/28480] Incorrect field ambiguity detection due to [[no_unique_address]] simark at simark dot ca
2021-11-25 12:56 ` cvs-commit at gcc dot gnu.org
2021-11-25 15:25 ` blarsen at redhat dot com
2021-12-11  7:49 ` cvs-commit 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-28480-4717-QkOA9LRHP0@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.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).