https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97829
Bug ID: 97829
Summary: pragma ignore "-Wint-in-bool-context" is ignored for
_Bool _Complex interaction
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: antiquarktv at gmail dot com
Target Milestone: ---
#include <stdio.h>
#include <stdlib.h>
// gcc -std=c11 -Wall -Wextra -pedantic main.c
#pragma GCC diagnostic ignored "-Wint-in-bool-context"
#pragma GCC diagnostic ignored "-Wunused-variable"
int main()
{
double _Complex x = 1;
_Bool b = 1;
b *= x; // prints int-in-bool-context warning.
_Bool c = 2; // unused var warning not printed.
}
/*
The code above prints the following when compiled:
gcc -std=c11 -Wall -Wextra -pedantic main.c
main.c: In function ‘main’:
cc1: warning: ‘*’ in boolean context, suggest ‘&&’ instead
[-Wint-in-bool-context]
cc1: warning: ‘*’ in boolean context, suggest ‘&&’ instead
[-Wint-in-bool-context]
The Wint-in-bool-context warning is printed by cc1 as a result of the _Bool *=
_Complex operation
If this code is compiled with -Wno-int-in-bool-context on the command line,
there is no warning:
gcc -std=c11 -Wall -Wextra -pedantic main.c -Wno-int-in-bool-context
(produces no output).
*/