[llvm-bugs] [Bug 42321] New: Assertion failure/wrong linkage for explicit specialisation of function templates, declared in an unnamed namespace

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 19 04:00:36 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42321

            Bug ID: 42321
           Summary: Assertion failure/wrong linkage for explicit
                    specialisation of function templates, declared in an
                    unnamed namespace
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: momchil.velikov at arm.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Testcase (https://gcc.godbolt.org/z/E85jsh):

inline namespace {
  template <typename T> int f() { return 0; }
  template <typename T> int g() { return 0; }
}

template<> int f<int>() { return 0; }
template int g<int>();

int (*pf)() = f<int>;
int (*pg)() = g<int>;


triggers assertion failure in debug builds:

$ ./bin/clang -S bb.cc -o - 
clang-9: /data/src/llvm-project/clang/lib/AST/Decl.cpp:1491: clang::LinkageInfo
clang::LinkageComputer::getLVForDecl(const clang::NamedDecl *,
clang::LVComputationKind): Assertion `!Old || Old->getCachedLinkage() ==
D->getCachedLinkage()' failed.


In release builds, the function `f<int>` has external linkage and filescope,
whereas `g<int>` has internal linkage and is in the unnamed namespace.

IIUC [temp.explicit] #6 and [temp.expl.spec] #8 both should be members of the
unnamed namespace and, following, [basic.link] #4, have internal linkage.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190619/91b8ccd5/attachment.html>


More information about the llvm-bugs mailing list