C++ Surprise 1 – const reference

“There are just two kinds of languages: the ones everybody complains about and the ones nobody uses.” — Bjarne

This doesn’t compile:

This does:

In the second case, y is initialized by a temporary double initialized from x. Not sure what the rationale is but read up TCPPPL 5.5.

Here is where the inconsistency becomes very difficult to ignore:

If anyone knows the reasoning behind this, let me know.