[clang] [clang] Fix assertion crash in alloc_size structural equivalence check (#199407) (PR #199980)
Marco Elver via cfe-commits
cfe-commits at lists.llvm.org
Wed May 27 10:50:19 PDT 2026
================
@@ -58,3 +58,11 @@ int main() {
my_malloc_fn_pointer_type f3 = fn2;
my_other_malloc_fn_pointer_type f4 = fn2;
}
+
+// Regression test for GH199407: structural equivalence of alloc_size attrs
+// with an unset optional ParamIdx must not crash.
+#define GH199407(Ty, Name) _Alignas(Ty) char Name[sizeof(Ty)]
+GH199407(struct GH199407S { float *f(long) __attribute__((alloc_size(1))); }, gbuf); // expected-error 2{{field 'f' declared as a function}} expected-error{{redefinition of 'GH199407S'}} expected-note{{previous definition is here}}
+// nonnull uses a VariadicParamIdx whose elements are always valid; verify no
+// regression for the valid-ParamIdx path in equalAttrArgs<ParamIdx>.
+GH199407(struct GH199407T { void *g(void *p) __attribute__((nonnull(1))); }, gbuf2); // expected-error 2{{field 'g' declared as a function}} expected-error{{redefinition of 'GH199407T'}} expected-note{{previous definition is here}}
----------------
melver wrote:
this is the `alloc-size.c` test, `nonnull` doesn't belong here.
https://github.com/llvm/llvm-project/pull/199980
More information about the cfe-commits
mailing list