-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

'Way back in February I was musing about the possibility of a mfbt
helper template that would allow us to silence "variable X might be
used uninitialized" warnings without the negative effects of
default-initializing those variables (mainly, that that could hide
bugs if a variable *is* used uninitialized).  I finally got around to
implementing something, and it seems to work pretty well -- well
enough for me to eliminate *all* of the maybe-uninitialized variable
warnings in layout/.  The patches are posted in this bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=1032994

The basic idea is that anytime you get a "may be used uninitialized"
warning, you can just change that variable's definition to

  CondSet<T> var;

which silences the compile-time warning and adds debug-only, fatal
runtime assertions that the variable is initialized at every point of
use.  You are somewhat limited in what you can do with such a
variable; the most important restriction is that you can't pass it to
a function with an out-parameter of type T* or T&.  You must instead
change that function to take CondSet<T>* or CondSet<T>&.  This is
because many such functions in our code base don't always write their
out-parameters; passing a reference to the CondSet object allows us to
track that dynamically and get the assertion right.

Other restrictions of note (unlike the above, these could potentially
change if it were needed) are that there is no copy constructor, and
that you can't store a NaN in CondSet<float> or CondSet<double>.  A
remaining major flaw, which I would welcome help correcting, is that
it also squelches "variable *is* used uninitialized" warnings.  (I'm
not sure this is possible to avoid, without asking the compiler folks
for a new __attribute__ or similar.)

I consider this to be preliminary work, so I'm asking for feedback
here rather than r?ing any of the patches.

zw
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQIcBAEBCAAGBQJTsxuSAAoJEJH8wytnaapkPSgP/15z2cWBFenZjo+1FxXIiRWq
tpteSKiFkmXB1aEYPSwkwH7pUJ44icHkixOSz6lYX4YdwCeYAWxCh5IlozCPLg81
4rGX0rql27oRd/RFnN9hNm/+zRtP/KKdjf94Tid6gDdW4k86Ce+AJ2QkkW/nL6JQ
kWJ5NkESImyLLu50RawzZyj1o/eQFEXl4pixSrqLcQ1Ozs0/Z/BMb3QARgWFLQ/y
AwTbe2IEfSogglhmZgh7RM8zwZmB/nkr2NRbsAwZ+qPrcEjmJntnzWq8ZrbBXJl6
OPlk8+lX6Vcrw3XgO/Olkr2Ie/tSuXgtL9PdVJVqnl2NJiq0UgX5Sms/PiqkohYQ
ojE23ESghVIMd430PBtOLAWOhBI77zg/frzkW9dkW2sJnxocnahNkk77a9Ml9X/4
Hyj0O7verHu4N8IbgV0Ojg3M20tVx4LInM7flZwCqlGkHpT3ztctgdUfx9090Thx
kx+0vMN5FAU7+GmNYzVuhweuVmrnfaympnbODlgNmrBLiWHrPdsHU8aoc1DH+ioG
jFm7c+py6MsuI2Z7inxAMNq0jYaOHw9s4tckGWOTDMYSOzMXNh0XVKaROSnn+LID
uBklD4yvYLafSbx/nCsQ5GapXysxmrZGGYW6LxcZ/NDYaZyLISGuV3JOxFygdgNH
iVCi18PyVB0NJP1K5KAn
=m+1i
-----END PGP SIGNATURE-----
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to