mark-zilber wrote:

Thanks for the feedback. I think the first point is already addressed. In last 
commit, following your question in the `DynamicType` thread, I rewrote the 
checker on top of `DynamicTypeInfo` and fixed `DynamicTypePropagation` instead 
of keeping a separate map (see Changes to DynamicTypePropagation in  the 
description). Placement new now records the exact type of the new object, 
including placement into a nonzero array element, and forgets the old type when 
the storage is reused through a byte offset; `new-dynamic-types.cpp` checks 
this through devirtualization

On the other placement new problems:
- `cplusplus.PlacementNew` already checks alignment when the storage is a 
variable, but a field or an element of one; storage reached through a pointer 
is not covered
-  I agree, that a missing destructor call before reusing the storage is often 
a bug (leak for example), but it is not undefined behavior by itself: 
[[basic.life]/6](https://eel.is/c++draft/basic.life#6) allows ending the 
lifetime of an object by reusing its storage. The undefined behavior comes when 
the destructor of the old type still runs on the new object, which is what this 
checker reports
- The old pointer remains usable when the new object transparently replaces the 
old one ([[basic.life]/10](https://eel.is/c++draft/basic.life#10)); otherwise 
`std::launder` is needed

I understand the concern about the size. Would it help if I split out the 
`DynamicTypePropagation` changes into a separate PR? They are useful on their 
own for devirtualization, and the checker would then be a smaller follow-up on 
top of them


https://github.com/llvm/llvm-project/pull/237801
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to