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

Aleksandr Platonov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 30 08:06:37 PDT 2020


ArcsinX marked an inline comment as done.
ArcsinX added inline comments.


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

----------------
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.


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