Associate information with a pointer address.
    BoQsc 
    vaidas.boqsc at gmail.com
       
    Fri Sep 29 14:31:54 UTC 2023
    
    
  
After being very happy about associative arrays of D Language, I 
encountered that they are not `@nogc`friendly. Unsure if I should 
wait for D language to support it, or do I need to rethink 
everything.
Error
```
onlineapp.d(20): Error: assigning an associative array element in 
`@nogc` function `D main` may cause a GC allocation
```
Source Code
```
import std;
void outofcontext() @nogc @system
{
     printf("Hello D ", associative);
     foreach (pointeraddress, information; associative){
		
        printf("%i", *cast(int *)pointeraddress);
     }
}
static string[void*] associative;
void main() @nogc @system
{
     printf("Hello D ", associative);
     int variable = 6;
     associative[&variable] = "someinformation";
     outofcontext();
}
```
    
    
More information about the Digitalmars-d-learn
mailing list