-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Labels
Type: InvalidOff topic for this repository, or a bug report determined to not actually represent a bugOff topic for this repository, or a bug report determined to not actually represent a bug
Description
I often see students write if (x = y) when they mean if (x == y). An understandable error; even a prof of C++ taking one of my intro classes made this same mistake in his code and wasn't able to see it.
Apparently gcc can be made to warn of assignments in if tests, by using the -Wparentheses flag at compilation. The warning can be avoided by using an extra pair of parentheses to demonstrate programmer's intention, i.e. if ((x = y)).
GNU's gcc -Wparentheses documentation.
As many users of the Arduino IDE are newer programmers and unlikely to intend assignments this way, I recommend that the warning for assignments inside of if() tests be made visible in the console.
Metadata
Metadata
Assignees
Labels
Type: InvalidOff topic for this repository, or a bug report determined to not actually represent a bugOff topic for this repository, or a bug report determined to not actually represent a bug