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

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