[Bug c++/96577] New: template binary bloat of two std::sort as an example. It looks like colonization is doing the wrong thing
euloanty at live dot com
gcc-bugzilla@gcc.gnu.org
Wed Aug 12 05:24:55 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96577
Bug ID: 96577
Summary: template binary bloat of two std::sort as an example.
It looks like colonization is doing the wrong thing
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: euloanty at live dot com
Target Milestone: ---
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.
BTW, inline function is not ABI stable, there is no reason not to collapse that
abstraction
More information about the Gcc-bugs
mailing list