I just changed the operator precedence for ?: to reflect the fact that it's the same precedence as assignment. To see that this is actually true, use a compiler of your choice, and evaluate the following piece of code:
int a = 0, b = 0; true ? a : b = 7;
After that, both a and b are zero, because due to right-to-left associativity (and equal precedence), the compiler sees it as (true ? a : (b = 7)), and will simply evaluate the a branch. If ?: was actually higher precedence than =, the value of a should be 7. Add parentheses to verify. Yes. It is surprising that essentially all precedence tables for C/C++/Java are wrong.
22.214.171.124 15:19, 10 September 2012 (PDT)
- Indeed, the grammar reference of the C++ standard lists the assignment and conditional operators as having the same precedence. Thanks for noticing. -- P12 15:41, 10 September 2012 (PDT)
 A simpler version
A link to http://cpp.operator-precedence.com was added to this page, presumably with the idea that it would be useful to have a simpler view of this chart. I've tentatively reverted the change, just to make sure it's not linkbait. Is such a link useful? Alternatively, could this chart be made clearer or simpler? One possibility might be to use color to help convey information. -Nate 00:45, 3 November 2012 (PDT)
- The current table gives more information and is more readable than the one at operator-precedence.com.
- The colors they chose to categorize the operators are hardly distinguishable, using brighter colors would make the page look very messy.
- --Bazzy 04:22, 3 November 2012 (PDT)
- I have the same opinion. P12 05:05, 3 November 2012 (PDT)