[Webkit-unassigned] [Bug 16317] New: Add strict_aliasing_cast<T>() to avoid need for custom unions

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 5 19:08:20 PST 2007


http://bugs.webkit.org/show_bug.cgi?id=16317

           Summary: Add strict_aliasing_cast<T>() to avoid need for custom
                    unions
           Product: WebKit
           Version: 523.x (Safari 3)
          Platform: Macintosh
               URL: http://trac.webkit.org/projects/webkit/changeset/28455
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: New Bugs
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: eric at webkit.org


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]);


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list