public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const'
@ 2012-12-10 16:29 dblaikie at gmail dot com
  2012-12-10 16:30 ` [Bug debug/55641] " dblaikie at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dblaikie at gmail dot com @ 2012-12-10 16:29 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55641

             Bug #: 55641
           Summary: debug info for the type of a reference declared with a
                    typedef has spurious 'const'
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dblaikie@gmail.com


Example code:

  typedef int &foo;
  int x;
  foo f(x);

under gdb run "whatis f" and the answer is "const foo" when it should be plain
"foo" (if you skip the typedef the answer is correctly "int&" not "int& const"
or any similarly strange mismatch)

Found in the GDB 7.5 test suite ( gdb.python/lib-types.exp ) - this is
positively tested for, but so far as I can imagine that's by accident, not
intent.


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
@ 2012-12-10 16:30 ` dblaikie at gmail dot com
  2012-12-10 17:24 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dblaikie at gmail dot com @ 2012-12-10 16:30 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55641

--- Comment #1 from David Blaikie <dblaikie at gmail dot com> 2012-12-10 16:29:47 UTC ---
Oh, and, tellingly, GCC (7.5) emits a DW_TAG_const_type in the DWARF data that
Clang does not emit, which seems to be the relevant difference here.


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
  2012-12-10 16:30 ` [Bug debug/55641] " dblaikie at gmail dot com
@ 2012-12-10 17:24 ` redi at gcc dot gnu.org
  2012-12-10 17:43 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2012-12-10 17:24 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55641

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-12-10 17:24:15 UTC ---
Which version of GCC? (there is no 7.5)


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
  2012-12-10 16:30 ` [Bug debug/55641] " dblaikie at gmail dot com
  2012-12-10 17:24 ` redi at gcc dot gnu.org
@ 2012-12-10 17:43 ` redi at gcc dot gnu.org
  2012-12-10 18:32 ` dblaikie at gmail dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2012-12-10 17:43 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55641

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-12-10
            Version|unknown                     |4.7.2
     Ever Confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-12-10 17:42:56 UTC ---
confirmed with various versions from 4.1 to 4.7


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
                   ` (2 preceding siblings ...)
  2012-12-10 17:43 ` redi at gcc dot gnu.org
@ 2012-12-10 18:32 ` dblaikie at gmail dot com
  2014-02-25 11:41 ` mark at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: dblaikie at gmail dot com @ 2012-12-10 18:32 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55641

--- Comment #4 from David Blaikie <dblaikie at gmail dot com> 2012-12-10 18:31:54 UTC ---
(In reply to comment #3)
> confirmed with various versions from 4.1 to 4.7

sorry, yes - I tested this with 4.7. Thanks for verifying the repro.


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
                   ` (3 preceding siblings ...)
  2012-12-10 18:32 ` dblaikie at gmail dot com
@ 2014-02-25 11:41 ` mark at gcc dot gnu.org
  2014-02-25 11:45 ` mark at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mark at gcc dot gnu.org @ 2014-02-25 11:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55641

Mark Wielaard <mark at gcc dot gnu.org> changed:

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

--- Comment #5 from Mark Wielaard <mark at gcc dot gnu.org> ---
Confirmed with g++ (GCC) 4.9.0 20140219 (experimental)

Variable f comes out as:

 [    48]    variable
             name                 (string) "f"
             decl_file            (data1) 1
             decl_line            (data1) 3
             type                 (ref4) [    5b]
             external             (flag_present) Yes
             location             (exprloc)               [   0] addr .rodata+0
<f>
 [    5b]    const_type
             type                 (ref4) [    1d]

With DIE 1d as expected:

 [    1d]    typedef
             name                 (string) "foo"
             decl_file            (data1) 1
             decl_line            (data1) 1
             type                 (ref4) [    28]
 [    28]    reference_type
             byte_size            (data1) 8
             type                 (ref4) [    2e]
 [    2e]    base_type
             byte_size            (data1) 4
             encoding             (data1) signed (5)
             name                 (string) "int"


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
                   ` (4 preceding siblings ...)
  2014-02-25 11:41 ` mark at gcc dot gnu.org
@ 2014-02-25 11:45 ` mark at gcc dot gnu.org
  2014-04-24  5:57 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mark at gcc dot gnu.org @ 2014-02-25 11:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55641

--- Comment #6 from Mark Wielaard <mark at gcc dot gnu.org> ---
Note that if we add:

  const foo g(x);

It comes out with just one const_type added:

 [    60]    variable
             name                 (string) "g"
             decl_file            (data1) 1
             decl_line            (data1) 4
             type                 (ref4) [    73]
             external             (flag_present) Yes
             location             (exprloc)               [   0] addr
.rodata+0x
8 <g>
 [    73]    const_type
             type                 (ref4) [    1d]

So the new DIE 73 is a duplicate of DIE 5b.


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
                   ` (5 preceding siblings ...)
  2014-02-25 11:45 ` mark at gcc dot gnu.org
@ 2014-04-24  5:57 ` pinskia at gcc dot gnu.org
  2014-08-06 16:14 ` tromey at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-04-24  5:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55641

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chihin.ko at oracle dot com

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 60948 has been marked as a duplicate of this bug. ***


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
                   ` (6 preceding siblings ...)
  2014-04-24  5:57 ` pinskia at gcc dot gnu.org
@ 2014-08-06 16:14 ` tromey at gcc dot gnu.org
  2014-09-22  9:06 ` mpolacek at gcc dot gnu.org
  2022-01-31 21:00 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at gcc dot gnu.org @ 2014-08-06 16:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Tom Tromey <tromey at gcc dot gnu.org> ---
I think this happens due to this code in gen_variable_die:

      tree type = TREE_TYPE (decl_or_origin);

      if (decl_by_reference_p (decl_or_origin))
    add_type_attribute (var_die, TREE_TYPE (type), 0, 0, context_die);
      else
    add_type_attribute (var_die, type, TREE_READONLY (decl_or_origin),
                TREE_THIS_VOLATILE (decl_or_origin), context_die);

For the reduced test case we enter the second call to add_type_attribute.
"g" is marked as TREE_READONLY, so this forces the "const" to be emitted.

Is there ever a case where this is correct?  That is, where the DWARF
needs to emit "const" or "volatile" but the only note is on the object
and not the object's type?  I didn't know.


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
                   ` (7 preceding siblings ...)
  2014-08-06 16:14 ` tromey at gcc dot gnu.org
@ 2014-09-22  9:06 ` mpolacek at gcc dot gnu.org
  2022-01-31 21:00 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-09-22  9:06 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Mark recently tweaked this code, but I still see the DW_TAG_const_type in
there.


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

* [Bug debug/55641] debug info for the type of a reference declared with a typedef has spurious 'const'
  2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
                   ` (8 preceding siblings ...)
  2014-09-22  9:06 ` mpolacek at gcc dot gnu.org
@ 2022-01-31 21:00 ` pinskia at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-31 21:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=61755
                 CC|                            |sijun.liu at oracle dot com

--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 61755 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2022-01-31 21:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-10 16:29 [Bug debug/55641] New: debug info for the type of a reference declared with a typedef has spurious 'const' dblaikie at gmail dot com
2012-12-10 16:30 ` [Bug debug/55641] " dblaikie at gmail dot com
2012-12-10 17:24 ` redi at gcc dot gnu.org
2012-12-10 17:43 ` redi at gcc dot gnu.org
2012-12-10 18:32 ` dblaikie at gmail dot com
2014-02-25 11:41 ` mark at gcc dot gnu.org
2014-02-25 11:45 ` mark at gcc dot gnu.org
2014-04-24  5:57 ` pinskia at gcc dot gnu.org
2014-08-06 16:14 ` tromey at gcc dot gnu.org
2014-09-22  9:06 ` mpolacek at gcc dot gnu.org
2022-01-31 21:00 ` pinskia 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).