https://issues.dlang.org/show_bug.cgi?id=15288
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|The exponentiation operator |The precedence of the |^^ doesn't follow the |exponentiation operator ^^ |standard type promotion |is too high. |rules. | --- Comment #1 from [email protected] --- So, I just realized what's actually going on here: the exponentiation operator *is* using the correct promotion rules, but, bizarrely, has higher precedence than the cast operator: I expect this: cast(N)1 ^^ cast(M)1 To be evaluated like this: (cast(N)1) ^^ (cast(M)1) But it is instead evaluated like this: cast(N)(1 ^^ cast(M)1) I'm not sure if anyone else actually uses this operator with integers, but if so I'd bet there are some bugs in the wild because of this. Looking at the operator precedence table on the dlang wiki: http://wiki.dlang.org/Operator_precedence I would say that groups 12 and 13 should be swapped. Otherwise you get truly weird stuff like: int[2] xs = [ 1, 2 ]; int* y = &(xs[0]); int z = *++y ^^ 7; // ERROR: incompatible types for ((y) ^^ (7)): 'int*' and 'int' Because this: *++y ^^ 7 Is interpreted as this: *++(y ^^ 7) Rather than what I would expect: (*++y) ^^ 7 Not only is this unexpected, it is also silly: * Exponentiation is not even defined for pointer types * The result of exponentiation cannot be incremented: it is an rvalue. * The dereference operator is not defined for integer types --
