Force -Werror for implicit int truncation for dom/canvas
Categories
(Core :: Graphics: CanvasWebGL, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: jgilbert, Assigned: jgilbert)
References
Details
(Whiteboard: gfx-noted)
Attachments
(7 files, 1 obsolete file)
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
We do a lot of validation, and we really don't want C++ truncating values behind our backs.
Assignee | ||
Comment 1•6 years ago
|
||
Assignee | ||
Comment 2•6 years ago
|
||
Depends on D25494
Assignee | ||
Comment 3•6 years ago
|
||
Depends on D25495
Assignee | ||
Comment 4•6 years ago
|
||
Depends on D25496
Assignee | ||
Comment 5•6 years ago
|
||
Depends on D25497
Assignee | ||
Comment 6•6 years ago
|
||
Depends on D25498
Assignee | ||
Comment 7•6 years ago
|
||
Depends on D25499
Assignee | ||
Comment 8•6 years ago
|
||
Depends on D25500
Assignee | ||
Updated•6 years ago
|
Comment 9•6 years ago
|
||
It looks like you're using C-style casts, i.e.
return (uint8_t)foo;
...or
return uint8_t(expression);
Given that we're now following Google's C++ coding style (per red-background note at old Mozilla Coding Style page), perhaps these should really be using static_cast<uint8_t>(...)
(or uint8_t{...}
) instead?
See this particular guideline:
Do not use C-style casts. Instead, use these C++-style casts when explicit type conversion is necessary.
- Use brace initialization to convert arithmetic types (e.g. int64{x}). This is the safest approach because code will not compile if conversion can result in information loss. The syntax is also concise.
- Use static_cast as the equivalent of a C-style cast that does value conversion, when you need to explicitly up-cast a pointer from a class to its superclass, or when you need to explicitly cast a pointer from a superclass to a subclass. In this last case, you must be sure your object is actually an instance of the subclass.
Assignee | ||
Comment 10•6 years ago
|
||
I suppose so, though last time I asserted that we should follow Google C++ style, I was rebuffed in favor of existing style! My understanding is that we've only adopted the Google C++ /whitespace/ style thus far.
Also, static_cast<>() might have the worst ergonomics in the world.
Assignee | ||
Updated•6 years ago
|
Comment 11•6 years ago
|
||
Comment 12•6 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/08d7c5e08995
https://hg.mozilla.org/mozilla-central/rev/89552599db42
https://hg.mozilla.org/mozilla-central/rev/54a2f08bcf48
https://hg.mozilla.org/mozilla-central/rev/f4debce94b00
https://hg.mozilla.org/mozilla-central/rev/c941cc70ee3e
https://hg.mozilla.org/mozilla-central/rev/54d64288d7de
https://hg.mozilla.org/mozilla-central/rev/093c37e856fb
Description
•