More than three Independent Units equals death

Create three Quantities with Independent Units:

In[3]:= a1 = Quantity[2, IndependentUnit["aaa"]]
Out[3]= Quantity[2, IndependentUnit["aaa"]]
In[4]:= a2 = Quantity[3, IndependentUnit["bbb"]]
Out[4]= Quantity[3, IndependentUnit["bbb"]]
In[6]:= a3 = Quantity[4, IndependentUnit["ccc"]]
Out[6]= Quantity[4, IndependentUnit["ccc"]]

Add two of them, and you get an “incompatible units” warning, but it works (in the purrely formal sense, like a complex number, which is fine):

In[7]:= a1 + a2
During evaluation of In[7]:= Quantity::compat: IndependentUnit[aaa] and IndependentUnit[bbb] are incompatible units >>
Out[7]= Quantity[2, IndependentUnit["aaa"]] + Quantity[3, IndependentUnit["bbb"]]

Try adding all three, and it hangs:

In[8]:= a1 + a2 + a3
During evaluation of In[8]:= Quantity::compat: IndependentUnit[aaa] and IndependentUnit[bbb] are incompatible units >>
During evaluation of In[8]:= Quantity::compat: IndependentUnit[aaa] and IndependentUnit[bbb] are incompatible units >>
During evaluation of In[8]:= Quantity::compat: IndependentUnit[aaa] and IndependentUnit[bbb] are incompatible units >>
During evaluation of In[8]:= General::stop: Further output of Quantity::compat will be suppressed during this calculation. >>
Out[8]= $Aborted

A fair amount of instability seems to accompany using IndependentUnits…kernel crashing out of the blue.

Anyone understand this?

It does not hang (Mma 9 on Windows 7 64 Bit), it reaches for some reason the $IterationLimit despite the fact that there is no iteration

a1 = Quantity[2, IndependentUnit["a1"]];
a2 = Quantity[3, IndependentUnit["a2"]];
a3 = Quantity[4, IndependentUnit["a3"]];


In[96]:= a1 + a2
During evaluation of In[96]:= Quantity::compat: IndependentUnit[a1] and IndependentUnit[a2] are incompatible units >>
Out[96]= Quantity[2, IndependentUnit["a1"]] + Quantity[3, IndependentUnit["a2"]]


In[100]:= a1 + a2 + a3 // Timing
During evaluation of In[100]:= Quantity::compat: IndependentUnit[a1] and IndependentUnit[a2] are incompatible units >>
During evaluation of In[100]:= Quantity::compat: IndependentUnit[a1] and IndependentUnit[a2] are incompatible units >>
During evaluation of In[100]:= Quantity::compat: IndependentUnit[a1] and IndependentUnit[a2] are incompatible units >>
During evaluation of In[100]:= General::stop: Further output of Quantity::compat will be suppressed during this calculation. >>
During evaluation of In[100]:= $IterationLimit::itlim: Iteration limit of 4096 exceeded. >>

Out[100]= {27.549777, 
 Hold[Quantity[4, IndependentUnit["a3"]] + 
   Block[{$AutomaticUnitPlus = False}, 
    Message[Quantity::compat, IndependentUnit["a1"], 
     IndependentUnit["a2"]]; 
    Quantity[2, IndependentUnit["a1"]] + 
     Quantity[3, IndependentUnit["a2"]]]]}

and this takes you only 27 and a half second.

This hang happens in version 9.0.0. It was fixed for 9.0.1.

$IterationLimit::itlim refers to an internal counter.