Do namespace objects declared with decltype(auto) for which a const qualified type is deduced have internal linkage?

40 views
Skip to first unread message

Tom Honermann

unread,
Sep 13, 2016, 12:33:25 PM9/13/16
to std-dis...@isocpp.org
Consider:

extern const int ci;
decltype(auto) aci = ci;

A strict reading of C++14 [basic.link] 3.5p3 suggests that 'aci' does
not have internal linkage:

"A name having namespace scope (3.3.6) has internal linkage if it is the
name of
— a variable, function or function template that is explicitly declared
static; or,
— a non-volatile variable that is explicitly declared const or constexpr
and neither explicitly declared extern nor previously declared to have
external linkage; or
— a data member of an anonymous union."

There appears to be implementation divergence. Clang (trunk) gives 'aci' internal linkage while gcc (6.2) gives it external linkage.

Tom.

T. C.

unread,
Sep 14, 2016, 5:28:01 AM9/14/16
to ISO C++ Standard - Discussion
This now says "of non-volatile const-qualified type".  See CWG 1686.

Tom Honermann

unread,
Sep 14, 2016, 9:00:04 AM9/14/16
to std-dis...@isocpp.org
Thank you!  (No idea why it didn't occur to me to, you know, actually check that exact same section in the WP.  Diligence failure on my part).

Tom.
Reply all
Reply to author
Forward
0 new messages