[Bug 147] GDC emits unnecessary dead struct inits

via D.gnu d.gnu at puremagic.com
Thu Jul 31 04:23:55 PDT 2014


http://bugzilla.gdcproject.org/show_bug.cgi?id=147

--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject.org> ---
The codegen is:

S a;              // memset(&a, 0, S.sizeof)
a.v = argv.length // a.v = argv.length

This first step is no easy to get around, as it is supposed to fill out any
alignment holes in the struct.

This itself ensures that 'assert(a == b)' is true in most cases (uses memcmp).


I do recognise that:

1) It's generally bad to use a == b to compare structs
2) Structs that return in registers have their 0'd alignment holes destroyed
with garbage.


Perhaps we shouldn't care about filling alignment holes, but that would break
the autotester (last time I checked), and maybe some code that relies on
memcmp'ing structs for equality.

-- 
You are receiving this mail because:
You are watching all bug changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20140731/da3fc2c9/attachment.html>


More information about the D.gnu mailing list