[Bug c/94012] New: Difference in gcc warning generation with c file and preprocessed file
vvijayan at mathworks dot com
gcc-bugzilla@gcc.gnu.org
Tue Mar 3 08:58:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94012
Bug ID: 94012
Summary: Difference in gcc warning generation with c file and
preprocessed file
Product: gcc
Version: 9.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: vvijayan at mathworks dot com
Target Milestone: ---
Hi,
I am observing a bit strange warning behaviour in gcc while compiling
preprocessed file.
Warning thrown is "Wint-in-bool-context"
Small testcase to reproduce the issue in given below
$cat test.c
#define my_strcmp(s1, s2) ((s1) == (s2) ? 0 : -1)
int next(const char* s1, const char* s2, int flag) {
if(!my_strcmp(s1, s2))
flag = 1;
return flag;
}
When compiled with gcc-8.3.0 (built from sources) observed following behaviour.
Compiling c file with -Wall - No warnings are thrown
====================================================
$gcc -c test.c -Wall
...
Compiling with -save-temps flag
===============================
$gcc -c test.c -Wall -save-temps
test.c: In function ‘next’:
test.c:6:27: warning: ?: using integer constants in boolean context
[-Wint-in-bool-context]
6 | if(!my_strcmp(s1, s2))
| ~~~~~~~~~~~~~~~~~~^
...
Try to compile the preprocessed file - Same warning is thrown
====================================
$gcc -c test.ii -Wall
test.cpp: In function ‘int next(const char*, const char*, int)’:
test.cpp:6:23: warning: ?: using integer constants in boolean context
[-Wint-in-bool-context]
6 | if(!my_strcmp(s1, s2))
| ~~~~~~~~~~~~~~^~~~
gcc -v
Using built-in specs.
COLLECT_GCC=../gcc-8.3.0/bin/gcc
COLLECT_LTO_WRAPPER=../8.3.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-8.3/configure --with-gmp=../gcc-8.3/gmp-4.3
--with-mpfr../gcc-8.3/mpfr --with-mpc=../gcc-8.3/mpc
--enable-languages=c,c++,fortran --enable-shared --enable-linker-build-id
--enable-plugin --enable-checking=release --enable-multiarch --enable-gold
--enable-ld=default --enable-libstdcxx-time=no --prefix=/opt/gcc-8.3.0
--with-pkgversion='GCC 8.3.0-gold' --with-tune=generic --with-system-zlib
--enable-multilib --with-multilib-list=m32,m64 --with-arch-directory=amd64
--with-arch-32=i586 --with-abi=m64
Thread model: posix
gcc version 8.3.0 (GCC 8.3.0-gold)
The issue exists in case of gcc-9.2.0 also.
$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=../gcc-9.2.0/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-9.2.0/configure --with-gmp=../gcc-9.2.0/gmp-4.3
--with-mpfr=../gcc-9.2.0/mpfr --with-mpc=../gcc-9.2.0/mpc
--enable-languages=c,c++,fortran --enable-shared --enable-linker-build-id
--enable-plugin --enable-checking=release --enable-multiarch --enable-gold
--enable-ld=default --enable-libstdcxx-time=no --prefix=/opt/gcc-9.2.0
--with-pkgversion='GCC 9.2.0-gold' --with-tune=generic --with-system-zlib
--enable-multilib --with-multilib-list=m32,m64 --with-arch-directory=amd64
--with-arch-32=i586 --with-abi=m64
Thread model: posix
gcc version 9.2.0
Encountered this issue in a distcc enabled build where the files are
prepossessed before they sent to remote machine.
Regards,
Vinitha Vijayan
More information about the Gcc-bugs
mailing list