On 23/10/17 17:07 +0200, Michael Matz wrote:
Hi,
On Mon, 23 Oct 2017, Richard Biener wrote:
I guess so. But we have to make gdb happy as well. It really depends how
much each TU grows with the extra (unneeded) include grows in C++11 and
C++04 mode.
The c++ headers unconditionally included from system.h, with:
% echo '#include <$name>' | g++-7 -E -x c++ - | wc -l
new: 3564
cstring: 533
utility: 3623
memory: 28066
That's using the -std=gnu++4 default for g++-7, and for that mode
the header *is* needed, to get the definition of std::unique_ptr.
For C++98 (when it isn't needed) that header is much smaller:
tmp$ echo '#include <memory>' | g++ -E -x c++ - | wc -l
28101
tmp$ echo '#include <memory>' | g++ -E -x c++ - -std=gnu++98 | wc -l
4267
(Because it doesn't contain std::unique_ptr and std::shared_ptr before
C++11).
compile time:
% echo -e '#include <$name>\nint i;' | time g++-7 -c -x c++ -
new: 0:00.06elapsed, 17060maxresident, 0major+3709minor
cstring: 0:00.03elapsed, 13524maxresident, 0major+3075minor
utility: 0:00.05elapsed, 16952maxresident, 0major+3776minor
memory: 0:00.25elapsed, 40356maxresident, 0major+9764minor
Hence, <memory> is not cheap at all, including it unconditionally from
system.h when it isn't actually used by many things doesn't seem a good
idea.
Ciao,
Michael.