I read a bit about the strict aliasing rule, and it seems that the only code 
that would be broken by "-fno-strict-aliasing" is code that declares two 
pointers to the same block of memory, and simultaneously uses both pointers to 
access the memory. I'd say that most programs, especially Nim programs, do not 
do this.

I see two potential problem areas:

The first potential problem area would be the garbage collector. If the garbage 
collector does this, then it must be converted to casting through unions, as 
Araq suggests.

The second potential problem area would be how the Nim garbage collector 
generates code for ref's and inheritance. If a ref is only used as one type, 
then there is no problem. If a ref is used as a parent type and a child type, 
then there is a potential problem there, depending on how the Nim compiler 
generates the cast for the ref.

After these two potential problems areas are evaluated and fixed, then 
"-fno-strict-aliasing" can be removed, as "safe" Nim code would not be able to 
violate the strict aliasing rule. Nim code that uses "cast" and ptr's in 
certain ways would still be able to violate the rule, but I would argue that it 
would be the programmer's responsibility to pass "-fno-strict-aliasing" to the 
compiler in this case.

Reply via email to