3 ms·
> Not sure exactly what you mean by aliasing bugs. I meant that if the same allocation were accessed as different kinds of objects, as if through a union, ...
by cryptonector 1y ago
> Not sure exactly what you mean by aliasing bugs.
I meant that if the same allocation were accessed as different kinds of objects, as if through a union, ... I guess what I really meant to ask is: does Fil-C know the types of objects being pointed to by a pointer, and therefore also the number of elements in arrays?
- pizlonator 1y agoIt’s a dynamically typed capability system. So, if you store a pointer to a location in memory and then load from that location using pointer type, then you get the capability that was last stored. But if the thing stored at the location was an integer, you get an invalid capability. So Fil-C’s “type” for an object is ever evolving. The memory returned from malloc will be nothing but invalid capabilities for each pointer width word in that allocation but as soon as you store pointers to it then the locations you stored those pointers to will be understood as being pointer locations. This makes unions and weird pointer casts just work. But you can ever type confuse an int with a pointer, or different pointer types, in a manner that would let you violate the capability model (ie achieve the kind of weird state where you can access any memory you like). Lots of tricks under the hood to make this thread safe and not too expensive.
- cryptonector 1y agoSo Fil-C has two types: pointers, and everything else. Clever.