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

            Bug ID: 69621
           Summary: extern std::string used as reference template-argument
                    does not have [abi:cxx11] tag applied
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ed at catmur dot co.uk
  Target Milestone: ---

#include <string>
template<std::string&> struct S { static void f(); };
extern std::string s;
void g() { S<s>::f(); }

asm emitted for g():
        jmp     S<s>::f()

Expected:
        jmp     S<s[abi:cxx11]>::f()

The latter will be emitted if there is a definition for the std::string in the
translation unit.

Broken versions: 5.1.0, 5.2.0, 5.3.0

Workaround: change S to take its template-parameter by pointer:
        jmp     S<&(s[abi:cxx11])>::f()

Original reporter:
http://stackoverflow.com/questions/35151104/stdstring-as-template-parameter-and-abi-tag-in-gcc-5

Possibly related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66971

Reply via email to