Date: Wed, 16 Nov 2022 11:17:22 -0800
On Wednesday, 16 November 2022 06:42:58 PST Jason McKesson via Std-Discussion
wrote:
> The literal
> text of the source code makes no sense, as far as the language is
> concerned. It is no different than if you wrote `a + - + - + c`.
Note, this expression *does* make sense and is allowed. The first + is the
binary addition operator; all the rest are unary prefixes. So this expression
is
a + (-(+(-(+c))))
If you remove the idempotent unary plus, you get
a + (-(-c))
And two negations is the same as doing nothing (ignoring the UB at INT_MIN),
resulting in a simple addition
a + c
Similarly, both a+++c and a---c are permitted, as are a*/*/*/c and a/*/*/*c.
None of those should pass a code review, of course.
wrote:
> The literal
> text of the source code makes no sense, as far as the language is
> concerned. It is no different than if you wrote `a + - + - + c`.
Note, this expression *does* make sense and is allowed. The first + is the
binary addition operator; all the rest are unary prefixes. So this expression
is
a + (-(+(-(+c))))
If you remove the idempotent unary plus, you get
a + (-(-c))
And two negations is the same as doing nothing (ignoring the UB at INT_MIN),
resulting in a simple addition
a + c
Similarly, both a+++c and a---c are permitted, as are a*/*/*/c and a/*/*/*c.
None of those should pass a code review, of course.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DCAI Cloud Engineering
Received on 2022-11-16 19:17:25