bulbazord added a comment.

In D153657#4449608 <https://reviews.llvm.org/D153657#4449608>, @jingham wrote:

> In D153657#4445292 <https://reviews.llvm.org/D153657#4445292>, @bulbazord 
> wrote:
>
>> I think this patch is probably okay to do, but it does break a supported use 
>> case that I'm aware of: One way you can do "object oriented programming" in 
>> C is to do exactly what you're trying to prevent. Using the test, you could 
>> say that "MyStruct" is the base class and "MyBiggerStruct" would be a 
>> derived class. You might have a pointer to a "MyStruct" object, even though 
>> you called `malloc(sizeof(MyBiggerStruct))`, and maybe you can perform that 
>> cast if you're sure that you actually have a `MyBiggerStruct` object.
>>
>> I know there's not necessarily a good way to support that without also 
>> supporting the bug you're trying to fix though. :(
>
> You can't actually cast structures to structures in C.  You can only cast 
> pointers.  So in your underlying code you always have to have pointers around 
> if you are playing these games, and you can cast the pointer to the derived 
> type and then dereference it, which is what you would have had to do in the 
> source language anyway.

Right, this makes sense, that was my disconnect. Thanks for clarifying and 
helping me understand!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153657

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

Reply via email to