Re: Wishlish: GCC option for explicit booleans

2005-10-04 Thread Jonathan Wakely
Peter Lupton NCH Swift Sound wrote: > But I have been going through other reports from the 'bug book' which I ask > my programmers to log. Another case which explicit bools would solve would > be (in Win32)... > > HANDLE hFile = CreateFile(...); > if (!hFile) return; > > If t

Re: Wishlish: GCC option for explicit booleans

2005-10-04 Thread Tommy Vercetti
On Tuesday 04 October 2005 15:39, Peter Lupton NCH Swift Sound wrote: > Richard: based on your argument all type checking is for nought :). > > But I have been going through other reports from the 'bug book' which I ask > my programmers to log. Another case which explicit bools would solve would >

Re: Wishlish: GCC option for explicit booleans

2005-10-04 Thread Peter Lupton NCH Swift Sound
Richard: based on your argument all type checking is for nought :). But I have been going through other reports from the 'bug book' which I ask my programmers to log. Another case which explicit bools would solve would be (in Win32)... HANDLE hFile = CreateFile(...); if (!hF

Re: Wishlish: GCC option for explicit booleans

2005-10-04 Thread Richard Guenther
On 10/4/05, Peter Lupton NCH Swift Sound <[EMAIL PROTECTED]> wrote: > Maybe I gave a too simple example on my first post. Another example common > error which would be prevented by blocking implicit bool conversion might be: > > if (strcmp(szMyName, "Peter")) printf("Hello Peter"); > > This ba

Re: Wishlish: GCC option for explicit booleans

2005-10-04 Thread Peter Lupton NCH Swift Sound
Maybe I gave a too simple example on my first post. Another example common error which would be prevented by blocking implicit bool conversion might be: if (strcmp(szMyName, "Peter")) printf("Hello Peter"); This bad error currently just slips through. If we gave an option to only accept ex

Re: Wishlish: GCC option for explicit booleans

2005-10-03 Thread Mike Stump
On Oct 2, 2005, at 5:27 PM, Nicholas Nethercote wrote: [~] g++ -Wall a.cpp a.cpp: In function `int main()': a.cpp:4: warning: suggest parentheses around assignment used as truth value And -Werror turns it into a hard error...

Re: Wishlish: GCC option for explicit booleans

2005-10-02 Thread Nicholas Nethercote
On Sat, 1 Oct 2005, [EMAIL PROTECTED] wrote: 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

Re: Wishlish: GCC option for explicit booleans

2005-10-02 Thread Bernhard R. Link
* Peter Lupton NCH Swift Sound <[EMAIL PROTECTED]> [051002 05:47]: > I was hoping was that we could at least have a compile option. So we could > turn it on if required. I would definitely mandate it in our organization > at least. I am sure others would too. I'd looked into getting some boolean

Re: Wishlish: GCC option for explicit booleans

2005-10-01 Thread Peter Lupton NCH Swift Sound
Hi Andrew, I was hoping was that we could at least have a compile option. So we could turn it on if required. I would definitely mandate it in our organization at least. I am sure others would too. We have a prepared list of common errors C++ novices make and the accidental boolean is always

Re: Wishlish: GCC option for explicit booleans

2005-10-01 Thread Robert Dewar
Andrew Pinski wrote: But any thing else would just be a violation of the C and C++ standards. I don't see that at all, optional switches/pragmas/directives that subset the language are in no ways violation of the standards. THe standard only requires that you have a mode in which the standard

Re: Wishlish: GCC option for explicit booleans

2005-10-01 Thread Andrew Pinski
> > 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

Wishlish: GCC option for explicit booleans

2005-10-01 Thread pl
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