Author: Timm Baeder Date: 2026-10-30T13:32:23+01:00 New Revision: cb909cac91a91c72a13e5621a537832d63351be5
URL: https://github.com/llvm/llvm-project/commit/cb909cac91a91c72a13e5621a537832d63351be5 DIFF: https://github.com/llvm/llvm-project/commit/cb909cac91a91c72a13e5621a537832d63351be5.diff LOG: [clang][bytecode] Reject non-readable pointer types from _load8 (#237146) Added: Modified: clang/lib/AST/ByteCode/InterpBuiltin.cpp clang/test/AST/ByteCode/c2y.c Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 8fefaa97c9f63..84edb0bce4a10 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -2237,6 +2237,9 @@ static bool interp__builtin_load8(InterpState &S, CodePtr OpPC, if (!isReadable(Ptr) && !Ptr.isOnePastEnd()) return false; + if (!Ptr.isReadablePointerType()) + return false; + if (IsAligned) { CharUnits RequiredAlign = S.getASTContext().getTypeAlignInChars(Call->getType()); diff --git a/clang/test/AST/ByteCode/c2y.c b/clang/test/AST/ByteCode/c2y.c index bbb163ab83833..7f5f0bc972fa1 100644 --- a/clang/test/AST/ByteCode/c2y.c +++ b/clang/test/AST/ByteCode/c2y.c @@ -1,8 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=expected,both -fexperimental-new-constant-interpreter // RUN: %clang_cc1 -triple x86_64-linux %s -std=c2y -verify=ref,both -// both-no-diagnostics - struct S { int x; char c; @@ -21,3 +19,10 @@ int quorble() { const struct S *s_ptr = (struct S *)((struct T *)buffer)->buffer; return s_ptr->x; } + + +__UINT_LEAST32_TYPE__ stdc_load8_aligned_leu32(const unsigned char *); +alignas(8) unsigned char buf[4] = {}; +__UINT_LEAST32_TYPE__ fail_load8 = stdc_load8_aligned_leu32(buf + 4); // both-error {{not a compile-time constant}} + + _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
