https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/237877
They can appear here in -fms-compatibility mode. >From 6178786f7bb6bcf95931a632d66f704ad6acf886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Mon, 2 Nov 2026 09:15:40 +0100 Subject: [PATCH] [clang][bytecode] Check for function pointers in __builtin_memcmp They can appear here in -fms-compatibility mode. --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 4 ++++ clang/test/AST/ByteCode/ms.cpp | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index c9f44807c9080..f2ff5083fe6ef 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -2328,6 +2328,10 @@ static bool interp__builtin_memcmp(InterpState &S, CodePtr OpPC, pushInteger(S, 0, Call->getType()); return true; } + + if (PtrA.isFunctionPointer() || PtrB.isFunctionPointer()) + return false; + bool IsWide = (ID == Builtin::BIwmemcmp || ID == Builtin::BI__builtin_wmemcmp); diff --git a/clang/test/AST/ByteCode/ms.cpp b/clang/test/AST/ByteCode/ms.cpp index b5c42e3ad78e2..ddce419a178ac 100644 --- a/clang/test/AST/ByteCode/ms.cpp +++ b/clang/test/AST/ByteCode/ms.cpp @@ -24,4 +24,7 @@ auto foo() { label: } // both-warning {{C++23 extension}} - +int somefunc(); +void fnptrinmemcmp() { static_assert(__builtin_memcmp(&somefunc, &somefunc, 1) == 0, ""); } // both-warning 2{{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}} \ + // both-error {{not an integral constant expression}} \ + // both-note {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
