~/talk

When the Compiler Gives You Errors, Make SFINAE

Talkat ACCU 2025 · 2025-04-01..04-04· [compilers-and-language-design]
links:none on file
slides:none on file

HLSL 2021 adds templates so SFINAE-style tricks and type traits are implemented inside shader code to detect an enum and bypass a compiler bug (#5553 in DirectXShaderCompiler) that makes sizeof on structs with enums bug refuse to compile. The workaround hoists enums into a base class, provides a custom size_of helper and enable_if-like traits, restores serialization offsets and static_assert checks, and successfully lets unit tests and serializers run despite HLSL static_assert and error-message quirks.

AI-written summary · about

  1. 0:00Introduction: Serialization and Offsets
  2. 0:29Adding Fields and the Hidden Offset Bug
  3. 0:44sizeof Enum Bug and Compiler Error
  4. 1:08Surprise! This Isn't C++, It's HLSL
  5. 1:28HLSL 2021: Templates Arrive
  6. 1:43Writing Type Traits and enable_if in HLSL
  7. 2:10Static Assert in HLSL vs C++
  8. 2:38A Workaround Using Inheritance
  9. 3:08Don't Be DenverCoder9: Share Your Fixes
  10. 3:51Conclusion and Talk Preview
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.