Skip to content

Conversation

@tbaederr
Copy link
Contributor

We can't read from non-block pointers anyway.

Fixes #165061

We can't read from non-block pointers anyway. Fixes llvm#165061
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Oct 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 25, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

We can't read from non-block pointers anyway.

Fixes #165061


Full diff: https://github.com/llvm/llvm-project/pull/165070.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+3)
  • (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+2)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index ff50e6dbfb44e..8dfeabe536654 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1941,6 +1941,9 @@ static bool interp__builtin_memcmp(InterpState &S, CodePtr OpPC, return true; } + if (!PtrA.isBlockPointer() || !PtrB.isBlockPointer()) + return false; + bool IsWide = (ID == Builtin::BIwmemcmp || ID == Builtin::BI__builtin_wmemcmp); diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 0b7d51be8d824..d8572ba722d69 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -1510,6 +1510,8 @@ namespace Memcmp { static_assert(f()); #endif + int unknown; + void foo(void) { unknown *= __builtin_memcmp(0, 0, 2); } } namespace Memchr { 
@tbaederr tbaederr merged commit 5d1e1cf into llvm:main Oct 27, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

2 participants