Bug 16317
| Summary: | Add strict_aliasing_cast<T>() to avoid need for custom unions | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Eric Seidel (no email) <eric> |
| Component: | New Bugs | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | mrobinson, mrowe, sam |
| Priority: | P2 | ||
| Version: | 523.x (Safari 3) | ||
| Hardware: | Mac | ||
| OS: | OS X 10.4 | ||
| URL: | http://trac.webkit.org/projects/webkit/changeset/28455 | ||
Eric Seidel (no email)
Add strict_aliasing_cast<T>() to avoid need for custom unions
We could do things like:
http://trac.webkit.org/projects/webkit/changeset/28455
Using a template function, which I think might lead to more readable code:
template<type T, type S>
strict_aliasing_cast<T>(S original)
{
union TmpUnion {
S original;
T casted;
};
TmpUnion u;
u.original = original;
return u.casted;
}
then that change just becomes:
return strict_aliasing_cast<TMalloc_Heap*>(&pageheap_memory[0]);
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Eric Seidel (no email)
Didn't sam already add something like this? If so, this should be closed.
Martin Robinson
If I'm not mistaken, this looks to be bitwise_cast in JavaScriptCore/wtf/StdLibExtras.h. So this bug can probably be closed.