[dmd-beta] D2 2.058 alpha

Jonathan M Davis jmdavisProg at gmx.com
Wed Feb 8 09:57:02 PST 2012


On Wednesday, February 08, 2012 18:15:30 Jacob Carlborg wrote:
> But if you put the "static if"-statement after all fields, shouldn't that be
> enough to have the full size of the struct. Of course it could be hard for
> the compiler to know that there are no fields after the "static
> if"-statement. Maybe the compiler could calculate the size incrementally.

That could cause big problems if the static if weren't after all of the member 
variables. You could have multiple static ifs, each of which ended up with a 
different size for the type, if there are member variables declared between 
them. We _could_ make it give an error if you then added a member variable 
after such a static if, but that's probably getting a bit complicated, since 
more state is necessary. So, it's probably better to just disallow such static 
ifs.

- Jonathan M Davis


More information about the dmd-beta mailing list