Michael Michael - 3 months ago 8
C++ Question

What does the compiler do here: int a = b * (c * d * + e)?

I had a strange bug in my program, and after a few hours of debugging, I found the following very stupid line:

int a = b * (c * d * + e)


If you don't see it: Between
d
and
e
I wrote
* +
, where just a
+
was intended.

Why does this compile and what does it actually mean?

Answer

The + is interpreted as an unary plus operator. It simply returns the promoted value of its operand.