g++ warn for conversion to bool

Jonny Grant jg@jguk.org
Wed May 20 23:52:27 GMT 2020


Hello
Is there a warning option for g++ to warn for implicit conversion to bool?

// g++-8 -Wall -o bool2 bool2.cpp
#include <stdio.h>

int main()
{
     int a = 3;
     bool b = a;

     printf("bool %d\n", b);
}


$ ./bool2
bool 1


Cheers, Jonny


More information about the Gcc-help mailing list