From: sotrdg sotrdg <euloanty@live.com>
To: "binutils@sourceware.org " <binutils@sourceware.org>
Subject: How does ld and gold deal with C++ duplicate templates?
Date: Wed, 16 Sep 2020 09:26:20 +0000 [thread overview]
Message-ID: <CH2PR02MB65228F0F549EF6905EFEF77BB2210@CH2PR02MB6522.namprd02.prod.outlook.com> (raw)
Like the bug I reported a month ago.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96577
https://godbolt.org/z/haG4E7
https://godbolt.org/z/M8e7Kb
First:
#include<vector>
#include<array>
#include<algorithm>
template<std::contiguous_iterator Iter>
void f(Iter a,Iter b)
{
std::sort(a,b);
}
void g(std::vector<int>::iterator b,std::vector<int>::iterator e)
{
f(b,e);
}
void h(int* b,int* e)
{
f(b,e);
}
Second:
#include<vector>
#include<array>
#include<algorithm>
template<std::contiguous_iterator Iter>
void f(Iter a,Iter b)
{
std::sort(a,b);
}
void g(std::vector<int>::iterator b,std::vector<int>::iterator e)
{
f(std::to_address(b),std::to_address(e));
}
void h(int* b,int* e)
{
f(b,e);
}
The two sort function should generate exactly the same binary. However the first which is none to_address version generates twice as much as code as the second one.
Will the GNU ld remove the duplication definitions?
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
next reply other threads:[~2020-09-16 9:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-16 9:26 sotrdg sotrdg [this message]
2020-09-16 19:23 ` Ian Lance Taylor
2020-09-16 19:38 ` sotrdg sotrdg
2020-09-16 20:56 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CH2PR02MB65228F0F549EF6905EFEF77BB2210@CH2PR02MB6522.namprd02.prod.outlook.com \
--to=euloanty@live.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).