MitalAshok wrote:

Could you knock out a related bug at the same time:

```c++
template<typename>
struct X {
  char arr[1];
};

extern X<void>* p, *q;
//X<void> inst;

void f() {
  __atomic_exchange(p, p, q, __ATOMIC_RELAXED);
}
```

With the line commented out, currently this crashes, but in Clang 18 and with 
your patch, it fails as `X<void>` hasn't been instantiated yet and 
`isTriviallyCopyableType` is false for incomplete types:

```
test:10:3: error: address argument to atomic operation must be a pointer to a 
trivially-copyable type ('X<void> *' invalid)
   10 |   __atomic_exchange(p, p, q, __ATOMIC_RELAXED);
      |   ^                 ~
```

`->isIncompleteType()` is true for uninstantiated templates too, so just a 
`RequireCompleteType` should stop the crash and instantiate templates as needed.

https://github.com/llvm/llvm-project/pull/96374
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to