Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e55a7c58d5721e23ace536f8187139cc31dd4b43
      
https://github.com/WebKit/WebKit/commit/e55a7c58d5721e23ace536f8187139cc31dd4b43
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-09-13 (Sun, 13 Sep 2026)

  Changed paths:
    M Source/WebCore/platform/graphics/FormatConverter.cpp

  Log Message:
  -----------
  convertFloatToHalfFloat() violates strict aliasing with a float*-to-unsigned* 
reinterpret_cast
https://bugs.webkit.org/show_bug.cgi?id=324095
rdar://187313552

Reviewed by Chris Dumez.

convertFloatToHalfFloat() read a float's storage through an
`unsigned*` lvalue via `*(reinterpret_cast<unsigned*>(&f))`. float
and unsigned are not similar types, so this is a strict-aliasing
violation: the compiler is free to assume the two lvalues do not
alias, making the result undefined. The function sits in the
per-pixel half-float conversion path, so the pattern is exercised
on every pixel of a HalfFloat texture pack.

Use std::bit_cast<uint32_t>(f), which reinterprets the bits by value
with no aliasing hazard and compiles to the same code. <bit> is
already available transitively through wtf/MathExtras.h.

No change in behavior.

* Source/WebCore/platform/graphics/FormatConverter.cpp:
(WebCore::convertFloatToHalfFloat):

Canonical link: https://commits.webkit.org/321017@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to