~/talk

To Int or To Uint

Talkat CppNorth 2024 Β· 2024-07-21..07-24Β· [security]
links:none on file
slides:none on file

Shows concrete x86 assembly (tested on Clang 14 and rechecked on Clang 17) and proves small choices change speed: averaging two numbers uses LEA+logical SHR for unsigned but extra sign-bit math and SAR for signed, making the signed path slightly slower; a handcrafted arithmetic-sum example lets the signed version be optimized into a closed form while the unsigned path suffers a 40Γ— slowdown due to UB and compiler conservatism. Recommends using sanitizers to catch signed overflow, prefer C++20/23 helpers (std::make_signed/unsigned, std::ssize), avoid auto for small literals, and enable warnings-as-errors.

AI-written summary Β· about

  1. 0:00Introduction and speaker background
  2. 3:22Basics of signed vs unsigned integers
  3. 15:14How signed integers are represented
  4. 23:24Performance differences in division
  5. 24:05Common pitfalls with integer types
  6. 39:37Arithmetic series benchmark
  7. 43:56Undefined behavior risks
  8. 47:09Compiler flags and sanitizers
  9. 50:40C++20 tools for integers
  10. 53:16Strong types and modern practices
  11. 59:01Q&A session
~/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.