glandium added a comment.

In D148827#4379764 <https://reviews.llvm.org/D148827#4379764>, @MaskRay wrote:

> These cases are UB and should be caught. It's not an excuse that they use C.

Are they really though?

  struct A {
    int a;
  };
  
  int foo(struct A *a) { return 42; }
  
  int bar(void *a) { return foo(a); }
  
  int main(void) {
    struct A a;
    bar(&a);
    int (*qux)(void *) = (int (*)(void *))foo;
    qux(&a); // If this is UB, why isn't the call to foo from bar?
    return 0;
  }

Likewise for `int foo()` and `int bar(void)`/`int (*qux)(void)`.
Likewise for `struct A* foo(void)` and `void *bar(void)`/`void *(*qux)(void)` 
(surprisingly, clang doesn't emit this error for `struct A* foo()` and `void* 
bar()`/`void*(*qux)()`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148827

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to