* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
@ 2004-11-01 19:05 ` pinskia at gcc dot gnu dot org
2004-11-01 23:52 ` giovannibajo at libero dot it
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-01 19:05 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-11-01 19:05 -------
The main reason IIRC for this is because C++ and export templates (even though we don't implement
export yet).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
2004-11-01 19:05 ` [Bug c++/18267] " pinskia at gcc dot gnu dot org
@ 2004-11-01 23:52 ` giovannibajo at libero dot it
2004-11-02 0:10 ` TazForEver at dlfp dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-01 23:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-11-01 23:52 -------
Names declared in anonymous namespaces do not get internal linkage by default.
In fact, they can be used as template non-type arguments (names with internal
linkage cannot be used in such contexts).
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
2004-11-01 19:05 ` [Bug c++/18267] " pinskia at gcc dot gnu dot org
2004-11-01 23:52 ` giovannibajo at libero dot it
@ 2004-11-02 0:10 ` TazForEver at dlfp dot org
2004-11-02 0:19 ` giovannibajo at libero dot it
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: TazForEver at dlfp dot org @ 2004-11-02 0:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From TazForEver at dlfp dot org 2004-11-02 00:10 -------
of course. but if they are not ? they should be optimize, no ?
if g++ inlines three(), why does it remove three() global definition if it's
never used ?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
` (2 preceding siblings ...)
2004-11-02 0:10 ` TazForEver at dlfp dot org
@ 2004-11-02 0:19 ` giovannibajo at libero dot it
2004-11-02 0:48 ` TazForEver at dlfp dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-02 0:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-11-02 00:19 -------
GCC is not allowed to remove the definition of a function with external
linkage. The fact that nobody will be able to call it because it is in an
anonymous namespace it is irrelevant.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
` (3 preceding siblings ...)
2004-11-02 0:19 ` giovannibajo at libero dot it
@ 2004-11-02 0:48 ` TazForEver at dlfp dot org
2004-11-02 1:22 ` giovannibajo at libero dot it
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: TazForEver at dlfp dot org @ 2004-11-02 0:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From TazForEver at dlfp dot org 2004-11-02 00:48 -------
i understand your point of view though i'm not happy with g++ behaviour. A
function with external linkage that can't be called seems like an oxymoron to
me. This makes my library very big. i had to mark a lot of functions inline to
get the behaviour i expect. But it is hard to manage. I have lo live with it.
Thanks for your explanation.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
` (4 preceding siblings ...)
2004-11-02 0:48 ` TazForEver at dlfp dot org
@ 2004-11-02 1:22 ` giovannibajo at libero dot it
2004-11-02 1:53 ` bangerth at dealii dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-02 1:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-11-02 01:22 -------
It is not exactly a G++ choice. This is what the ISO/ANSI C++ International
Standard mandates. I suggest you to post a mail to the newsgroup
comp.lang.c++.moderated or to comp.std.c++ to enquire an explanation for the
rationale.
Also, notice you can try compiling your code with -ffunction-sections to let
the linker drop the unused functions from the final executable. But remember
that this option might regress the code performance a bit on x86 because it
forces the compiler to generate slower code for each function call.
Alternatively, why don't you simply use "static"?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
` (5 preceding siblings ...)
2004-11-02 1:22 ` giovannibajo at libero dot it
@ 2004-11-02 1:53 ` bangerth at dealii dot org
2004-11-02 9:21 ` TazForEver at dlfp dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-11-02 1:53 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-11-02 01:53 -------
This point has been discussed in a number of PRs already. I maintain
my position that gcc could invoke the as-if rule to give these functions
internal linkage if they aren't taken as template parameters. Since
there is no user-visible effect, this is well within the allowed range,
and it would save us from a good number of the problems we've had over
time with mangling of symbol names in anonymous namespaces.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
` (6 preceding siblings ...)
2004-11-02 1:53 ` bangerth at dealii dot org
@ 2004-11-02 9:21 ` TazForEver at dlfp dot org
2004-11-02 11:55 ` giovannibajo at libero dot it
2004-11-02 16:10 ` bangerth at dealii dot org
9 siblings, 0 replies; 11+ messages in thread
From: TazForEver at dlfp dot org @ 2004-11-02 9:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From TazForEver at dlfp dot org 2004-11-02 09:21 -------
>> Alternatively, why don't you simply use "static"?
because everybody tells me that 'static' is deprecated in favor of 'namespace{}'
>> gcc could invoke the as-if rule to give these functions internal linkage
this sounds great.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
` (7 preceding siblings ...)
2004-11-02 9:21 ` TazForEver at dlfp dot org
@ 2004-11-02 11:55 ` giovannibajo at libero dot it
2004-11-02 16:10 ` bangerth at dealii dot org
9 siblings, 0 replies; 11+ messages in thread
From: giovannibajo at libero dot it @ 2004-11-02 11:55 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-11-02 11:55 -------
(In reply to comment #7)
> This point has been discussed in a number of PRs already. I maintain
> my position that gcc could invoke the as-if rule to give these functions
> internal linkage if they aren't taken as template parameters. Since
> there is no user-visible effect, this is well within the allowed range,
> and it would save us from a good number of the problems we've had over
> time with mangling of symbol names in anonymous namespaces.
I don't think it would solve the problem about mangling because the
function/classes in anonymous namespaces can still be used as template
arguments, so they could end up being mangled.
But it is an interesting point of view.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/18267] external linkage of functions declared in an anonymous namespace
2004-11-01 18:30 [Bug c++/18267] New: external linkage of functions declared in an anonymous namespace TazForEver at dlfp dot org
` (8 preceding siblings ...)
2004-11-02 11:55 ` giovannibajo at libero dot it
@ 2004-11-02 16:10 ` bangerth at dealii dot org
9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2004-11-02 16:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-11-02 16:10 -------
I don't want to have these symbols not mangled (they need indeed be
mangled and randomized), the problem is that the randomness is sometimes
not enough. See PR 9393 for a case that would have been solved with
making symbols have internal linkage.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18267
^ permalink raw reply [flat|nested] 11+ messages in thread