C++ Logo

STD-DISCUSSION

Advanced search

Subject: Any progress with P0537? How to proceed?
From: Deniz Bahadir (deniz.bahadir_at_[hidden])
Date: 2020-07-16 05:06:16


Hello everyone,

I was lately playing around with symbol visibility and C++ attributes in
Clang and I stumbled over a problem that was described by Matthew
Woehlke in his proposal paper P0537 ("Allow Attributes on Template
Explicit Instantiations").

Clang currently does not allow C++ attributes at explicit template
instantiations [1], because the C++ standard explicitly says that it
would be illegal.
However, it would be needed if one wants to make such an explicitly
instantiated type visible from outside the shared library it is compiled
in (using C++ attribute syntax).

E.g., the following is not supported by Clang:

```
template <typename T>
T foo(T) { return 0; }

template [[gnu::visibility("default")]]
int foo<int>(int);
```

However, using the compiler-specific syntax is accepted by Clang:

```
template <typename T>
T foo(T) { return 0; }

template __attribute__((gnu::visibility("default")))
int foo<int>(int);
```

By the way, GCC accepts both.

In the associated Clang bug-ticket [1] Matthew mentions his proposal
P0537 [2] and the result of the EWG poll from 2017 Kona committee
meeting [3].

There seemed to be consensus that P0537 points out a C++ defect and that
all compilers should support C++ attributes at explicit template
instantiations (as does GCC).

However, I was unable to find this mentioned in any C++ defect report.
In fact, the problematic sentence is still in the latest draft for
C++20. And Clang still does not support it with the upcoming Clang 11.

Does anyone know what is missing to get this into the list of C++
defects or to remove the problematic sentence from the C++ standard
entirely? (Who has to proceed how?)

Thanks for your insights,
Deniz Bahadir

[1] https://bugs.llvm.org/show_bug.cgi?id=29094
[2] https://wg21.link/p0537
[3] https://bugs.llvm.org/show_bug.cgi?id=29094#c5

-- 
BENOCS GmbH
Dipl.-Inform. Deniz Bahadir
Reuchlinstr. 10 D
10553 Berlin
Germany
Phone: +49 - 30 / 577 0004-22
Email: deniz.bahadir_at_[hidden]
www.benocs.com
Board of Management: Stephan Schröder, Dr.-Ing. Ingmar Poese
Commercial Register: Amtsgericht Bonn HRB 19378

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups