This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Wishlish: GCC option for explicit booleans
- From: <pl at nch dot com dot au>
- To: <gcc at gcc dot gnu dot org>
- Date: Sat, 1 Oct 2005 23:04:27 -0400 (EDT)
- Subject: Wishlish: GCC option for explicit booleans
C++ would be a better language if the boolean type did not implicitly
convert from int. For example, many novice programmers make the
mistake.
if (i = j) dosomething(); // Should be i == j
If conversion to boolean required explicit this would all be solved. It
would mean all the old code with expressions like "while (p) ... "
would need to be changed to "while (p != NULL) ...". But I think the
change would be well justified.
What about a GCC option to turn off implicit conversion to boolean?
I for one will require all code written in this company to use the option.
It would save many bugs.
Note: C# does this. While I don't like C# - it is one good feature.