public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions
@ 2015-08-24 22:23 ian at airs dot com
  2015-08-24 22:26 ` [Bug c++/67343] " ian at airs dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ian at airs dot com @ 2015-08-24 22:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67343
           Summary: C++ mangler does not follow ABI for local names in
                    expressions
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ian at airs dot com
                CC: jason at gcc dot gnu.org
  Target Milestone: ---

If I compile this C++ file with current mainline

template<bool B> class H {
 public:
  enum T { V = B };
};

template <typename T> class C {
 public:
  enum { B1 = true, B2 = false };
};

template<typename T>
void f(typename H<C<T>::B1 && !C<T>::B2>::T) {}

void g() {
  f<int>(H<true>::V);
}

I get this symbol:

_Z1fIiEvN1HIXaasr1CIT_E2B1ntsrS3_2B2EE1TE

I believe that this symbol is not mangled according to the current C++ mangling
ABI.  The relevant part is the expression Xaasr1CIT_E2B1ntsrS3_2B2E,
specifically the local name sr1CIT_E2B1.  The mangling ABI says

<unresolved-name> ::= [gs] <base-unresolved-name>
                  ::= sr <unresolved-type> <base-unresolved-name>
                  ::= srN <unresolved-type> <unresolved-qualifier-level>+ E
<base-unresolved-name>
                  ::= [gs] sr <unresolved-qualifier-level>+ E
<base-unresolved-name>


<unresolved-type> ::= <template-param>
                  ::= <decltype>
                  ::= <substitution>

The string after "sr" is 1CIT_E2B1.  The 1C is not a template-param, a
decltype, or a substitution.  Therefore we must be using the fourth expansion
of <unresolved-name>, where we expect to see a series of
<unresolved-qualifier-level> entries, followed by an E, followed by a
<base-unresolved-name>.  But in fact what we see here is <type>
<unqualified-name>.  This is what the code in cp/mangle.c outputs:

          write_string ("sr");
          write_type (scope);
          write_member_name (member);

Either the mangling ABI or GCC itself is wrong.


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

* [Bug c++/67343] C++ mangler does not follow ABI for local names in expressions
  2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
@ 2015-08-24 22:26 ` ian at airs dot com
  2020-08-29  4:25 ` jason at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ian at airs dot com @ 2015-08-24 22:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Ian Lance Taylor <ian at airs dot com> ---
For the record, when the same file is compiled with clang, the symbol is
_Z1fIiEvN1HIXaasr1CIT_EE2B1ntsr1CIS1_EE2B2EE1TE .  This symbol does appear to
follow the current API.  The relevant part of the expression here is
sr1CIT_EE2B1 .


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

* [Bug c++/67343] C++ mangler does not follow ABI for local names in expressions
  2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
  2015-08-24 22:26 ` [Bug c++/67343] " ian at airs dot com
@ 2020-08-29  4:25 ` jason at gcc dot gnu.org
  2020-08-29  4:27 ` jason at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2020-08-29  4:25 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |guilherme at amadio dot org

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
*** Bug 85648 has been marked as a duplicate of this bug. ***

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

* [Bug c++/67343] C++ mangler does not follow ABI for local names in expressions
  2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
  2015-08-24 22:26 ` [Bug c++/67343] " ian at airs dot com
  2020-08-29  4:25 ` jason at gcc dot gnu.org
@ 2020-08-29  4:27 ` jason at gcc dot gnu.org
  2020-12-19 15:51 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2020-08-29  4:27 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-08-29
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

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

* [Bug c++/67343] C++ mangler does not follow ABI for local names in expressions
  2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
                   ` (2 preceding siblings ...)
  2020-08-29  4:27 ` jason at gcc dot gnu.org
@ 2020-12-19 15:51 ` jason at gcc dot gnu.org
  2020-12-19 15:51 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2020-12-19 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |brennan at umanwizard dot com

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
*** Bug 88413 has been marked as a duplicate of this bug. ***

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

* [Bug c++/67343] C++ mangler does not follow ABI for local names in expressions
  2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
                   ` (3 preceding siblings ...)
  2020-12-19 15:51 ` jason at gcc dot gnu.org
@ 2020-12-19 15:51 ` jason at gcc dot gnu.org
  2020-12-22  2:17 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2020-12-19 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
*** Bug 89818 has been marked as a duplicate of this bug. ***

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

* [Bug c++/67343] C++ mangler does not follow ABI for local names in expressions
  2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
                   ` (4 preceding siblings ...)
  2020-12-19 15:51 ` jason at gcc dot gnu.org
@ 2020-12-22  2:17 ` cvs-commit at gcc dot gnu.org
  2020-12-22  2:33 ` [Bug c++/67343] C++ mangler does not follow ABI for unresolved " jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-12-22  2:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:58fb912c15175f4444144b8a4ab52a4880b84994

commit r11-6300-g58fb912c15175f4444144b8a4ab52a4880b84994
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Dec 21 17:36:25 2020 -0500

    c++: Fix demangling of <unresolved-name>

    The ABI for unresolved scoped names on the RHS of . and -> used to be

      sr <type> <unqualified-id>

    That changed years ago to something more complex, but G++ was never
updated.
    This change was particularly incompatible for simple qualified-ids like
    A::x, which were previously mangled as sr1A1x, and now sr1AE1x.

    This obviously makes life hard for demanglers, which can't know whether to
    consume that E or not.  To work around this, we now try demangling with the
    newer ABI, and if that fails and we saw an "sr", try again with the older
    ABI.

    libiberty/ChangeLog:

            PR c++/67343
            * cp-demangle.h (struct d_info): Add unresolved_name_state.
            * cp-demangle.c (d_prefix): Add subst parm.
            (d_nested_name): Pass it.
            (d_unresolved_name): Split out from...
            (d_expression_1): ...here.
            (d_demangle_callback): Maybe retry with old sr mangling.
            * testsuite/demangle-expected: Add test.

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

* [Bug c++/67343] C++ mangler does not follow ABI for unresolved names in expressions
  2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
                   ` (5 preceding siblings ...)
  2020-12-22  2:17 ` cvs-commit at gcc dot gnu.org
@ 2020-12-22  2:33 ` jason at gcc dot gnu.org
  2020-12-22  2:34 ` jason at gcc dot gnu.org
  2023-10-05 22:32 ` jason at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2020-12-22  2:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Created attachment 49828
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49828&action=edit
WIP Fix

Here's my current patch for this bug, but I think I'm going to hold off on it
pending the resolution of ABI issue 38.

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

* [Bug c++/67343] C++ mangler does not follow ABI for unresolved names in expressions
  2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
                   ` (6 preceding siblings ...)
  2020-12-22  2:33 ` [Bug c++/67343] C++ mangler does not follow ABI for unresolved " jason at gcc dot gnu.org
@ 2020-12-22  2:34 ` jason at gcc dot gnu.org
  2023-10-05 22:32 ` jason at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2020-12-22  2:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Created attachment 49829
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49829&action=edit
Follow-on patch

And this one fixes ->:: according to the current ABI, but also holding for the
issue resolution.

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

* [Bug c++/67343] C++ mangler does not follow ABI for unresolved names in expressions
  2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
                   ` (7 preceding siblings ...)
  2020-12-22  2:34 ` jason at gcc dot gnu.org
@ 2023-10-05 22:32 ` jason at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2023-10-05 22:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yedeng.yd at linux dot alibaba.com

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> ---
*** Bug 109887 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2023-10-05 22:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-24 22:23 [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions ian at airs dot com
2015-08-24 22:26 ` [Bug c++/67343] " ian at airs dot com
2020-08-29  4:25 ` jason at gcc dot gnu.org
2020-08-29  4:27 ` jason at gcc dot gnu.org
2020-12-19 15:51 ` jason at gcc dot gnu.org
2020-12-19 15:51 ` jason at gcc dot gnu.org
2020-12-22  2:17 ` cvs-commit at gcc dot gnu.org
2020-12-22  2:33 ` [Bug c++/67343] C++ mangler does not follow ABI for unresolved " jason at gcc dot gnu.org
2020-12-22  2:34 ` jason at gcc dot gnu.org
2023-10-05 22:32 ` jason 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).