Is there a warning for a string literal for converting bool to gcc

In a fairly large code base, I found the following construct (rewritten snippet) in a cpp file

int main()
{
    bool b;
    //... some code ...;
    b = "False"
}

This is a fully legal code, but clearly not intentional. It is easily fixed, but it has been present since 2014, and no one notices it, so it is clearly not easy to detect.

Can gcc be a warning about this?

+4
source share
1 answer

Neither g ++ 7 nor clang ++ 5 warn with -Wall -Wextra -Wpedantic.

Clang -Wstring-conversion, , gcc . gcc , .

enter image description here

live wandbox


gcc-: # 80151.

+2

Source: https://habr.com/ru/post/1672923/


All Articles