GNOME Bugzilla – Bug 488689
Compiler warning for use of "exp" as variable-name
Last modified: 2021-07-05 13:21:30 UTC
While compiling libxml2-2.6.27 (and the sections of code look unchanged in 2.6.30) on OS X 10.3 (gcc3.3), I get warnings: /bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I. -I./include -I./include -D_REENTRANT -I/sw/include -I/sw/include -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c -o xmlregexp.lo xmlregexp.c gcc -DHAVE_CONFIG_H -I. -I. -I. -I./include -I./include -D_REENTRANT -I/sw/include -I/sw/include -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c xmlregexp.c -fno-common -DPIC -o .libs/xmlregexp.o xmlregexp.c:6582: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:6624: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:6733: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:6778: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:6786: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:6846: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:6862: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:6869: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:6991: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:7010: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:7026: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:7044: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:7105: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:7559: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here xmlregexp.c:7593: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here and later: gcc -DHAVE_CONFIG_H -I. -I. -I. -I./include -I./include -D_REENTRANT -I/sw/include -I/sw/include -g -O2 -pedantic -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -c testapi.c testapi.c: In function `test_xmlExpGetLanguage': testapi.c:32552: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here testapi.c: In function `test_xmlExpGetStart': testapi.c:32607: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here testapi.c: In function `test_xmlExpIsNillable': testapi.c:32660: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here testapi.c: In function `test_xmlExpRef': testapi.c:32787: warning: declaration of `exp' shadows a global declaration <built-in>:0: warning: shadowed declaration is here testapi.c: In function `test_xmlExpSubsume': testapi.c:32832: warning: declaration of `exp' shadows a global declaration You and I know that you mean a local variable, but the compiler can't read our minds:( Safer to use a symbol "regexp" or "expr" or somesuch?
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.