* [Bug c++/35688] template visibility botch
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
@ 2010-10-27 22:10 ` pinskia at gcc dot gnu.org
2011-11-06 12:14 ` [Bug c++/35688] template visibility not overridden by template arguments paolo.carlini at oracle dot com
` (14 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-10-27 22:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2010.10.27 22:10:38
Ever Confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-10-27 22:10:38 UTC ---
Confirmed. The reason why they should be hidden is because the template
argument is hidden.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
2010-10-27 22:10 ` [Bug c++/35688] template visibility botch pinskia at gcc dot gnu.org
@ 2011-11-06 12:14 ` paolo.carlini at oracle dot com
2011-11-06 13:20 ` jason at gcc dot gnu.org
` (13 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-11-06 12:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|gcc-bugs at gcc dot gnu.org |jason at gcc dot gnu.org
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-06 12:13:47 UTC ---
I think this is essentially invalid/by design, it's core visibility part of the
issue we have been discussing lately with Vincenzo, for example: he sees the
visibility("default") decorations on namespace std an annoyance exactly because
of this behavior wrt user-code instantiations of namespace std templates.
Is this core mechanism ever going to change? Jason?
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
2010-10-27 22:10 ` [Bug c++/35688] template visibility botch pinskia at gcc dot gnu.org
2011-11-06 12:14 ` [Bug c++/35688] template visibility not overridden by template arguments paolo.carlini at oracle dot com
@ 2011-11-06 13:20 ` jason at gcc dot gnu.org
2011-11-06 13:22 ` jason at gcc dot gnu.org
` (12 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-06 13:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-06 13:20:22 UTC ---
Ah, need to use constrain_visibility_for_template for function templates as
well as class templates.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2011-11-06 13:20 ` jason at gcc dot gnu.org
@ 2011-11-06 13:22 ` jason at gcc dot gnu.org
2011-11-06 20:37 ` jason at gcc dot gnu.org
` (11 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-06 13:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-06 13:21:35 UTC ---
No, I was misreading the code, it should already deal with function templates.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2011-11-06 13:22 ` jason at gcc dot gnu.org
@ 2011-11-06 20:37 ` jason at gcc dot gnu.org
2011-11-06 21:14 ` paolo.carlini at oracle dot com
` (10 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-06 20:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |jason at gcc dot gnu.org
|gnu.org |
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2011-11-06 20:37 ` jason at gcc dot gnu.org
@ 2011-11-06 21:14 ` paolo.carlini at oracle dot com
2011-11-07 4:41 ` jason at gcc dot gnu.org
` (9 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-11-06 21:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|jason at gcc dot gnu.org |vincenzo.innocente at cern
| |dot ch
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-06 21:12:52 UTC ---
Ah! Let's keep Vincenzo up to date about this.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2011-11-06 21:14 ` paolo.carlini at oracle dot com
@ 2011-11-07 4:41 ` jason at gcc dot gnu.org
2011-11-07 9:24 ` vincenzo.innocente at cern dot ch
` (8 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-07 4:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-07 04:40:25 UTC ---
Author: jason
Date: Mon Nov 7 04:40:14 2011
New Revision: 181069
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181069
Log:
PR c++/35688
gcc/c-common/
* c-common.c (decl_has_visibility_attr): Split out from...
(c_determine_visibility): ...here.
* c-common.h: Declare it.
gcc/cp/
* decl2.c (constrain_visibility): Check decl_has_visibility_attr
rather than DECL_VISIBILITY_SPECIFIED.
Added:
trunk/gcc/testsuite/g++.dg/ext/visibility/template7.C
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/c-family/c-common.h
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl2.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2011-11-07 4:41 ` jason at gcc dot gnu.org
@ 2011-11-07 9:24 ` vincenzo.innocente at cern dot ch
2011-11-07 9:39 ` vincenzo.innocente at cern dot ch
` (7 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2011-11-07 9:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #7 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-11-07 09:23:30 UTC ---
The situation now is even more confused.
Most of the std algos have iterators as arguments. Visibility seems not to
propagate there..
below is my extensive test
compile as
c++ -O0 -shared -fPIC -fvisibility=hidden -o bha.so testICF.cpp
nm bha.so | c++filt
and look at the mixture of " t " and " T "
for instance
000000000000ad7f t void std::__adjust_heap<__gnu_cxx::__normal_iterator<C**,
std::vector<C*, std::allocator<C*> > >, long,
C*>(__gnu_cxx::__normal_iterator<C**, std::vector<C*, std::allocator<C*> > >,
long, long, C*)
000000000000afea T void
std::__iter_swap<true>::iter_swap<__gnu_cxx::__normal_iterator<C**,
std::vector<C*, std::allocator<C*> > >, __gnu_cxx::__normal_iterator<C**,
std::vector<C*, std::allocator<C*>
etc
cat testICF.cpp
#include<vector>
#include<algorithm>
#include<cmath>
struct A {
A(float q=0): v(q){}
float v;
bool operator<(A const & a) const { return v<a.v;}
};
struct B {
B(float q=0): v(q){}
bool operator<(B const & a) const { return v<a.v;}
float v;
};
struct C {
C(double q=0): v(q){}
bool operator<(C const & a) const { return v<a.v;}
double v;
};
float cosq(A const & a) {
return cos(a.v);
}
float cosq(B const & a) {
return cos(a.v);
}
template<typename T>
int game(std::vector<T> const & a, std::vector<T> & b) {
typedef typename std::vector<T>::const_iterator Iter;
for (Iter i=a.begin(); i!=a.end(); ++i) {
if ( (*i).v>0.) b.push_back((*i).v+1);
}
std::sort(b.begin(),b.end());
return b.size();
}
template<typename T>
int gamep(std::vector<T*> const & a, std::vector<T*> & b) {
typedef typename std::vector<T*>::const_iterator Iter;
for (Iter i=a.begin(); i!=a.end(); ++i) {
if ( (*i)->v>0.) b.push_back((*i));
}
std::sort(b.begin(),b.end());
return b.size();
}
namespace data /* __attribute__((visibility("default"))) */ {
std::vector<A> a;
std::vector<B> b;
std::vector<C> c;
std::vector<A*> ap;
std::vector<B*> bp;
std::vector<C*> cp;
}
#include<iostream>
int __attribute__((visibility("default"))) go() {
using namespace data;
int ret=0;
try {
ret+=game(a,a);
ret+=game(b,b);
ret+=game(c,c);
ret+=gamep(ap,ap);
ret+=gamep(bp,bp);
ret+=gamep(cp,cp);
} catch (std::exception & ce) {
std::cout << ce.what() << std::endl;
}
return ret;
}
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2011-11-07 9:24 ` vincenzo.innocente at cern dot ch
@ 2011-11-07 9:39 ` vincenzo.innocente at cern dot ch
2011-11-07 17:55 ` jason at gcc dot gnu.org
` (6 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2011-11-07 9:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #8 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-11-07 09:38:08 UTC ---
Reduced test
actually it is enough to add
s::foo(v);
in the main after s::foo(a);
to get
0000000000000e34 t void s::foo<A>(A)
0000000000000e3a T void s::foo<s::vector<A> >(s::vector<A>)
0000000000000e2a t s::vector<A>::vector()
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2011-11-07 9:39 ` vincenzo.innocente at cern dot ch
@ 2011-11-07 17:55 ` jason at gcc dot gnu.org
2011-11-07 21:18 ` jason at gcc dot gnu.org
` (5 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-07 17:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-07 17:51:43 UTC ---
Author: jason
Date: Mon Nov 7 17:51:40 2011
New Revision: 181102
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181102
Log:
PR c++/35688
* decl2.c (constrain_visibility): Return void. Add tmpl parm
which gives the constraint priority over an attribute.
(constrain_visibility_for_template, determine_visibility): Adjust.
* pt.c (instantiate_class_template_1): Call determine_visibility.
Added:
trunk/gcc/testsuite/g++.dg/ext/visibility/template8.C
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/c-family/c-common.h
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl2.c
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (9 preceding siblings ...)
2011-11-07 17:55 ` jason at gcc dot gnu.org
@ 2011-11-07 21:18 ` jason at gcc dot gnu.org
2011-11-07 21:25 ` jason at gcc dot gnu.org
` (4 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-07 21:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #10 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-07 21:17:28 UTC ---
Created attachment 25744
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25744
patch for 4.6
I think I'm not going to apply this to release branches, as it's a pretty
significant change in behavior, but here's a patch against 4.6 if people want
to apply it locally.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (10 preceding siblings ...)
2011-11-07 21:18 ` jason at gcc dot gnu.org
@ 2011-11-07 21:25 ` jason at gcc dot gnu.org
2011-11-08 8:53 ` vincenzo.innocente at cern dot ch
` (3 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2011-11-07 21:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.7.0
--- Comment #11 from Jason Merrill <jason at gcc dot gnu.org> 2011-11-07 21:17:48 UTC ---
Fixed for 4.7.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (11 preceding siblings ...)
2011-11-07 21:25 ` jason at gcc dot gnu.org
@ 2011-11-08 8:53 ` vincenzo.innocente at cern dot ch
2012-12-08 12:10 ` Woebbeking at web dot de
` (2 subsequent siblings)
15 siblings, 0 replies; 16+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2011-11-08 8:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #12 from vincenzo Innocente <vincenzo.innocente at cern dot ch> 2011-11-08 08:49:22 UTC ---
much better!
for the test in comment 7 now I get
c++ -O0 -shared -fPIC -fvisibility=hidden -o bha.so testICF.cpp
nm bha.so | c++filt | grep " T "
0000000000000e5c T go()
00000000000069ce T unsigned long const& std::max<unsigned long>(unsigned long
const&, unsigned long const&)
00000000000010b2 T std::__lg(long)
00000000000010d8 T operator new(unsigned long, void*)
puzzled by the visibility of std::max above I modified the original test
further as
cat visTest.cc
namespace s __attribute__((visibility("default"))) {
template <class T>
class vector {
public:
vector() { }
};
template <class T>
void foo(T t) {
}
}
class A {
public:
A() { }
s::vector<int> v;
};
s::vector<A> v;
int main() {
A a;
s::foo(a);
s::foo(v);
s::foo(a.v);
return 0;
}
and I get default visibility for s::vector<int>, as expected. not necessarily
as wished…
In my opinion this is consistent with spec, expect bug reports though!
c++ -O0 -shared -fPIC -fvisibility=hidden -o bha.so visTest.cc
nm bha.so | c++filt
0000000000000d77 t __GLOBAL__sub_I_visTest.cc
0000000000000d4c t __static_initialization_and_destruction_0(int, int)
0000000000000d8c t A::A()
0000000000000dba t void s::foo<A>(A)
0000000000000dc0 t void s::foo<s::vector<A> >(s::vector<A>)
0000000000000dc6 T void s::foo<s::vector<int> >(s::vector<int>)
0000000000000db0 t s::vector<A>::vector()
0000000000000da6 T s::vector<int>::vector()
0000000000000d04 t __dyld_func_lookup
0000000000000d0a t _main
0000000000001038 d _v
U dyld_stub_binder
0000000000000cf0 t dyld_stub_binding_helper
p.s I verified that if "s" in NOT default visible vector<int> will become
hidden
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (12 preceding siblings ...)
2011-11-08 8:53 ` vincenzo.innocente at cern dot ch
@ 2012-12-08 12:10 ` Woebbeking at web dot de
2013-02-10 15:50 ` Woebbeking at web dot de
2013-02-11 15:45 ` jason at gcc dot gnu.org
15 siblings, 0 replies; 16+ messages in thread
From: Woebbeking at web dot de @ 2012-12-08 12:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
André Wöbbeking <Woebbeking at web dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Woebbeking at web dot de
--- Comment #13 from André Wöbbeking <Woebbeking at web dot de> 2012-12-08 12:09:37 UTC ---
HI,
I've the following problem with this: 3rd party libs don't "export" their
templates, e. g. Boost doesn't export shared_ptr. So if I use a shared_ptr as
template parameter the template itself isn't exported.
I don't understand why fully declared templates like Boost's shared_ptr have a
visibility at all.
I know that C++11's shared_ptr is exported but that doesn't help me now.
Do I've to change my code or is this a regression or is it Boost's fault?
Cheers,
André
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (13 preceding siblings ...)
2012-12-08 12:10 ` Woebbeking at web dot de
@ 2013-02-10 15:50 ` Woebbeking at web dot de
2013-02-11 15:45 ` jason at gcc dot gnu.org
15 siblings, 0 replies; 16+ messages in thread
From: Woebbeking at web dot de @ 2013-02-10 15:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #14 from André Wöbbeking <Woebbeking at web dot de> 2013-02-10 15:50:14 UTC ---
Could anyone reply to my last question? Thanks in advance.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug c++/35688] template visibility not overridden by template arguments
[not found] <bug-35688-4@http.gcc.gnu.org/bugzilla/>
` (14 preceding siblings ...)
2013-02-10 15:50 ` Woebbeking at web dot de
@ 2013-02-11 15:45 ` jason at gcc dot gnu.org
15 siblings, 0 replies; 16+ messages in thread
From: jason at gcc dot gnu.org @ 2013-02-11 15:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35688
--- Comment #15 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-11 15:44:51 UTC ---
(In reply to comment #13)
> I don't understand why fully declared templates like Boost's shared_ptr have a
> visibility at all.
I'm not sure why they would. Are you compiling with -fvisibility=hidden? If
so, you need to explicitly give everything that you want to be exported the
appropriate visibility.
> Do I've to change my code or is this a regression or is it Boost's fault?
You might wrap the #includes in
#pragma GCC visibility push(default)
#pragma GCC visibility pop
to give the Boost library all default visibility.
^ permalink raw reply [flat|nested] 16+ messages in thread