On Mon, 29 Jun 2015 03:10:44 +0000, Tofu Ninja wrote: > On Monday, 29 June 2015 at 02:31:18 UTC, ketmar wrote: >> yes. it doesn't do that now, afair, but i can't see any sense in >> running code that obviously does nothing, as it's owner is not used. >> module ctors was designed for such things -- i.e. to run some code on >> startup. if someone is doing some vital initialization in static ctor >> of struct or class, and that struct or class aren't used anywhere else >> in his code, he's doing it wrong. it *may* work now, but that's simply >> 'cause compiler is not very well at removing unused code. > > That seems wrong, what if I am doing separate compilation, how would the > compiler know if the type is going to be used or not...
it doesn't really matter if you compiled your code separate or not: compiler *has* to know everything to successfully link the program. and it knows. for now it doesn't do much with that info, though, as using binutils for languages like D sux: D needs it's own compiled module format and optimising linker. but as i told ealier, this is the limitiation of current implementation, not guarantee.
signature.asc
Description: PGP signature