Re: Template friend function injection
Victor Bazarov wrote:
Tried it with GCC 4.2.3 on Ubuntu. Here's the output:
Ubuntu-bazarov:~$ g++ test_template.c pp
/tmp/ccCNJWBg.o: In function `main':
test_template.c pp:(.text+0x12) : undefined reference to `Function()'
collect2: ld returned 1 exit status
Ubuntu-bazarov:~$ g++ -c test_template.c pp -o test_template.o
Ubuntu-bazarov:~$ nm test_template.o
U _Z8Functionv
U __gxx_personali ty_v0
00000000 T main
Ubuntu-bazarov:~$
As we can see, the function 'Function' does not get defined in the
module although the template Test is instantiated. That looks like an
oversight on GCC part :*)
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Victor Bazarov wrote:
H9XLrv5oXVNvHiU I@spambox.us wrote:
>
I wasn't sure whether you meant the code you posted or some other code
in which the template and its explicit instantiation were in a different
(than 'main') translation unit. Can you try your code on a different
compiler? I am going to try in GCC on Linux. Will report with results
in a few minutes...
>On Jul 11, 7:53 pm, Victor Bazarov <v.Abaza...@com Acast.netwrote:
>>
>I don't understand the question. I'm talking about the code I posted,
>which doesn't compile as well as my real code I'm working on.
>>H9XLrv5oXVNvH ...@spambox.us wrote:
>>>[..]
>>>From what I know a function gets inlined only when declaration and
>>>definition occur in the same place, which is not true for my code.
>>Is that code different from what you posted?
>>>
>>>[..]
>>>From what I know a function gets inlined only when declaration and
>>>definition occur in the same place, which is not true for my code.
>>Is that code different from what you posted?
>>>
>I don't understand the question. I'm talking about the code I posted,
>which doesn't compile as well as my real code I'm working on.
I wasn't sure whether you meant the code you posted or some other code
in which the template and its explicit instantiation were in a different
(than 'main') translation unit. Can you try your code on a different
compiler? I am going to try in GCC on Linux. Will report with results
in a few minutes...
Ubuntu-bazarov:~$ g++ test_template.c pp
/tmp/ccCNJWBg.o: In function `main':
test_template.c pp:(.text+0x12) : undefined reference to `Function()'
collect2: ld returned 1 exit status
Ubuntu-bazarov:~$ g++ -c test_template.c pp -o test_template.o
Ubuntu-bazarov:~$ nm test_template.o
U _Z8Functionv
U __gxx_personali ty_v0
00000000 T main
Ubuntu-bazarov:~$
As we can see, the function 'Function' does not get defined in the
module although the template Test is instantiated. That looks like an
oversight on GCC part :*)
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Comment