News for hackers. Stuff that matters.
Re:Why Does “=” Mean Assignment? by jandrese on Tuesday April 10, 2018 @05:00PM (#16805368)
Don't compilers warn about assignment inside of conditionals now?
Re:Why Does “=” Mean Assignment? by gumby on Tuesday April 10, 2018 @05:16PM (#16805523)
In C++17 not only can you do assignment in the conditional, you can declare new variables which have the scope of the then and else clauses.

But yes, most compilers will catch this case.

Re:Why Does “=” Mean Assignment? by gowld on Wednesday April 11, 2018 @12:55AM (#16808149)
The compiler warns unless you add an extra () around the assignment to signal that you mean it.
Re:Why Does “=” Mean Assignment? by OskarS on Tuesday April 10, 2018 @05:17PM (#16805530)
It's used often enough in loops like this:

    while (v = next()) { ... }
or, perhaps more usefully:

    while ((v = next()) != ERROR) { ... }
EDIT: just did a quick check, and LLVM did in fact warn me about this:

    if (x = 4) { ... }
To silence the error, you have to double up on the parenthesis, which I guess is a reasonable enough solution:

    if ((x = 4)) { ... }