01d04a93ddfb — Leonard Ritter 21 days ago
* allow explicit casting of pointers to other types, preserving storage class
1 files changed, 6 insertions(+), 1 deletions(-)

M lib/scopes/core.sc
M lib/scopes/core.sc +6 -1
@@ 2759,7 2759,12 @@ fn pointer-as (vT T)
     if (type< T pointer)
         let ST = ('storageof T)
         if (icmp== ('kind ST) type-kind-pointer)
-            if (icmp== ('pointer-storage-class vT) ('pointer-storage-class T))
+            let vC = ('pointer-storage-class vT)
+            let C = ('pointer-storage-class T)
+            if (icmp== vC C)
+                return `(inline (self) (bitcast self T))
+            if (icmp== C unnamed)
+                let T = ('change-storage-class T vC)
                 return `(inline (self) (bitcast self T))
     elseif (type== T intptr)
         return `(inline (self) (ptrtoint self T))