public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55655] New: cannot export specialized template
@ 2012-12-11 20:15 mw_triad at users dot sourceforge.net
2012-12-11 20:49 ` [Bug c++/55655] " redi at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: mw_triad at users dot sourceforge.net @ 2012-12-11 20:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55655
Bug #: 55655
Summary: cannot export specialized template
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: mw_triad@users.sourceforge.net
Let us say I have a generic template class, e.g. my_smart_ptr. Let us also say
I have a class 'foo', 'clas foo : public my_smart_ptr<bar>' that is part of
some library public API. And last, let us say that 'foo' needs to specialize
'my_smart_ptr<bar>'.
As far as I can tell, it is impossible to export this instantiation with proper
symbol visibility in this configuration. I do NOT want to make all possible
instantiations of my_smart_ptr have default visibility (someone, somewhere may
have an instantiation that should have hidden visibility).
I need to do two things, but they are mutually contradictory:
1. I need to explicitly instantiate the template in order to give it default
visibility. However, if I do this first, it prevents specialization. (I also
get compiler errors for my specific use case, as generic instantiation is not
possible.)
2. I need to declare specialization prior to instantiation. However, if I do
this before instantiation, I cannot set default visibility on the instantiation
and I get link errors.
I think there should be a way to do this... Right now I am forced to not export
the template, requiring each user to use their own instantiation, which creates
a fragile ABI.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/55655] cannot export specialized template
2012-12-11 20:15 [Bug c++/55655] New: cannot export specialized template mw_triad at users dot sourceforge.net
@ 2012-12-11 20:49 ` redi at gcc dot gnu.org
2012-12-11 21:06 ` mw_triad at users dot sourceforge.net
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2012-12-11 20:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55655
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2012-12-11
Ever Confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-12-11 20:48:56 UTC ---
(In reply to comment #0)
> Let us say I have a generic template class, e.g. my_smart_ptr. Let us also say
> I have a class 'foo', 'clas foo : public my_smart_ptr<bar>' that is part of
> some library public API. And last, let us say that 'foo' needs to specialize
> 'my_smart_ptr<bar>'.
Please provide some code instead of saying it. It's much easier to talk about
concrete examples, with the compiler commands used.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/55655] cannot export specialized template
2012-12-11 20:15 [Bug c++/55655] New: cannot export specialized template mw_triad at users dot sourceforge.net
2012-12-11 20:49 ` [Bug c++/55655] " redi at gcc dot gnu.org
@ 2012-12-11 21:06 ` mw_triad at users dot sourceforge.net
2012-12-11 21:49 ` redi at gcc dot gnu.org
2012-12-11 23:34 ` mw_triad at users dot sourceforge.net
3 siblings, 0 replies; 5+ messages in thread
From: mw_triad at users dot sourceforge.net @ 2012-12-11 21:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55655
--- Comment #2 from Matthew Woehlke <mw_triad at users dot sourceforge.net> 2012-12-11 21:06:26 UTC ---
Created attachment 28930
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28930
example code
Here's a simplified concrete example. Since we are talking about correct
visibility, -fvisibility=hidden or #pragma equivalent is implied; otherwise,
compile flags do not (AFAIK) matter.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/55655] cannot export specialized template
2012-12-11 20:15 [Bug c++/55655] New: cannot export specialized template mw_triad at users dot sourceforge.net
2012-12-11 20:49 ` [Bug c++/55655] " redi at gcc dot gnu.org
2012-12-11 21:06 ` mw_triad at users dot sourceforge.net
@ 2012-12-11 21:49 ` redi at gcc dot gnu.org
2012-12-11 23:34 ` mw_triad at users dot sourceforge.net
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2012-12-11 21:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55655
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-12-11 21:49:13 UTC ---
Which symbols are hidden which you don't want to be?
What do you mean "instantiation failed"? You get a warning but it works.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/55655] cannot export specialized template
2012-12-11 20:15 [Bug c++/55655] New: cannot export specialized template mw_triad at users dot sourceforge.net
` (2 preceding siblings ...)
2012-12-11 21:49 ` redi at gcc dot gnu.org
@ 2012-12-11 23:34 ` mw_triad at users dot sourceforge.net
3 siblings, 0 replies; 5+ messages in thread
From: mw_triad at users dot sourceforge.net @ 2012-12-11 23:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55655
--- Comment #4 from Matthew Woehlke <mw_triad at users dot sourceforge.net> 2012-12-11 23:34:21 UTC ---
(In reply to comment #3)
> Which symbols are hidden which you don't want to be?
ptr<object>
> What do you mean "instantiation failed"? You get a warning but it works.
It fails if you haven't declared the specialization, which is necessary to get
the correct visibility of ptr<object>. With the specialization declare,
instantiation "succeeds" but with the wrong visibility.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-12-11 23:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-11 20:15 [Bug c++/55655] New: cannot export specialized template mw_triad at users dot sourceforge.net
2012-12-11 20:49 ` [Bug c++/55655] " redi at gcc dot gnu.org
2012-12-11 21:06 ` mw_triad at users dot sourceforge.net
2012-12-11 21:49 ` redi at gcc dot gnu.org
2012-12-11 23:34 ` mw_triad at users dot sourceforge.net
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).