Skip to content

variable template specialization is treated as only a declaration if its type has internal linkage #19434

@zygoloid

Description

@zygoloid
mannequin
Bugzilla Link 19060
Version unspecified
OS Linux
CC @akyrtzi

Extended Description

We're failing to instantiate the initializer for a variable template specialization if its type has internal linkage:

<stdin>:1:24: warning: variable 'var<<anonymous namespace>::S>' has internal linkage but is not defined [-Wundefined-internal]
template<typename T> T var; namespace { struct S {} s = var<S>; }
                       ^
<stdin>:1:57: note: used here
template<typename T> T var; namespace { struct S {} s = var<S>; }
                                                        ^

The warning is sort of right: if we emit IR for s, we emit it as external global.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++14clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions