[PATCH] D82805: [clang] Fix a crash on passing C structure of incompatible type to function with reference parameter

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 30 08:39:50 PDT 2020


riccibruno added inline comments.


================
Comment at: clang/test/Sema/init-ref-c.c:8
+}
\ No newline at end of file

----------------
ArcsinX wrote:
> riccibruno wrote:
> > I think it would be better to name this test `varargs-arm.c` since this bug can only happen with the varargs-related builtins (`__builtin_addressof` takes a reference but has custom type-checking).
> > 
> > Additional test case:
> > ```
> > const __builtin_va_list cva;
> > __builtin_va_end(cva); // expected-error {{binding reference of type '__builtin_va_list' to value of type 'const __builtin_va_list' drops 'const' qualifier}}
> > ```
> It's not only about ARM, its about `__builtin_va_list` type which depends on architecture. E.g. on MIPS it also crashes.
> 
> Also it's not about `__builtin_va_*()` and `__builtin_ms_va_*()`,  its about builtins with reference parameters, when we pass incompatible C structures to these builtin calls. May be there could be other builtins with reference parameters in the future.
> 
> We could not pass incompatible structure to `__builtin_addressof()` that is the reason why we could not reproduce the problem with this builtin.
> It's not only about ARM, its about `__builtin_va_list` type which depends on architecture.
> E.g. on MIPS it also crashes.

Sure.

> Also it's not about `__builtin_va_*()` and `__builtin_ms_va_*()`, its about built-ins with
> reference parameters, when we pass incompatible C structures to these builtin calls.
> May be there could be other built-ins with reference parameters in the future.

Right, but currently only these built-ins and `__builtin_addressof()` have a parameter of reference type, and as you said `__builtin_addressof()` doesn't have this problem.

That said it's not a big deal so I think it's fine if you want to leave it here.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82805/new/

https://reviews.llvm.org/D82805





More information about the cfe-commits mailing list