[Issue 7319] .bss section not used
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Nov 3 22:59:55 PST 2014
https://issues.dlang.org/show_bug.cgi?id=7319
Marco Leise <Marco.Leise at gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|minor |normal
--- Comment #4 from Marco Leise <Marco.Leise at gmx.de> ---
Three years later and this is still open. I don't think it is the difficulty of
the problem. I'm raising this to 'normal'. Here is a test case that _should_
result in a few KiB executable, but creates a 7 MiB one. Every instantiation of
the templated structs adds 1 MiB. Some, but not all of these unnecessary .inits
are also accessible at runtime:
---------8<-------------
import std.typetuple;
import std.stdio;
struct StuffDefault(T) { T[1024 * 1024] m_data; }
struct StuffVoid(T) { T[1024 * 1024] m_data = void; }
struct StuffZero(T) { T[1024 * 1024] m_data = 0; }
void main(string[] args)
{
alias Ts = TypeTuple!(
StuffDefault!void,
StuffVoid!void,
StuffDefault!ubyte,
StuffVoid!ubyte,
StuffZero!ubyte,
StuffVoid!char,
StuffZero!char,
);
// .inits visible at runtime
foreach (T; Ts) {
writefln("Does %s have a superfluous init? %s",
T.stringof, typeid(T).init.ptr is null ? "no" : "YES");
}
}
----------->8------------
Prints:
Does StuffDefault!void have a superfluous init? no
Does StuffVoid!void have a superfluous init? YES
Does StuffDefault!ubyte have a superfluous init? no
Does StuffVoid!ubyte have a superfluous init? YES
Does StuffZero!ubyte have a superfluous init? YES
Does StuffVoid!char have a superfluous init? YES
Does StuffZero!char have a superfluous init? YES
--
More information about the Digitalmars-d-bugs
mailing list