public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ian at airs dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/67343] New: C++ mangler does not follow ABI for local names in expressions
Date: Mon, 24 Aug 2015 22:23:00 -0000	[thread overview]
Message-ID: <bug-67343-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2015-08-24 22:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-24 22:23 ian at airs dot com [this message]
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

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