[all-commits] [llvm/llvm-project] 85c502: [clang][bytecode] Fix crash when dereferencing cas...

puneeth_aditya_5656 via All-commits all-commits at lists.llvm.org
Tue Feb 3 22:48:39 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 85c50299172bbd36ac345d5f50bce4bfee1e5667
      https://github.com/llvm/llvm-project/commit/85c50299172bbd36ac345d5f50bce4bfee1e5667
  Author: puneeth_aditya_5656 <myakampuneeth at gmail.com>
  Date:   2026-02-04 (Wed, 04 Feb 2026)

  Changed paths:
    M clang/lib/AST/ByteCode/Pointer.cpp
    M clang/test/AST/ByteCode/invalid.cpp

  Log Message:
  -----------
  [clang][bytecode] Fix crash when dereferencing cast to larger type (#179030)

## Summary
When dereferencing a pointer that was `reinterpret_cast` to a larger
type (e.g. `*(int**)""`), the bytecode interpreter would crash with an
assertion failure because it tried to read more bytes than the
allocation contained.

## Changes
- Add a size check in `Pointer::toRValue()` before calling `deref<T>()`
to ensure the allocation is large enough
- If the allocation is too small, return `std::nullopt` to gracefully
fail the constant evaluation instead of crashing
- Add regression test

Fixes #179015



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


More information about the All-commits mailing list