ModularM
Modular2y ago
6 replies
ivellapillil

Bug or optimisation

The following code:

struct A:
    fn __init__(inout self): ...
    
fn main(): 
    print(UnsafePointer.address_of(A()) == UnsafePointer.address_of(A())) # Prints True


indicates that both initialised empty struct has the same address. Are empty structs automatically "singleton"? Or is it a bug in the compiler? I am using Mac M1.
Was this page helpful?