Re: [pcre-dev] Compiler warnings in JIT with NEON instructio…

トップ ページ
このメッセージを削除
著者: ph10
日付:  
To: Petr Pisar
CC: pcre-dev
題目: Re: [pcre-dev] Compiler warnings in JIT with NEON instructions
On Thu, 7 Nov 2019, Petr Pisar via Pcre-dev wrote:

> I can see GCC 4.8.5 prints these warnings on 32-bit PowerPC:
>
> gcc -DHAVE_CONFIG_H -I. -I./src  "-I./src"     -pthread -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m32 -mcpu=power7 -mtune=power7 -c -o src/pcre2test-pcre2test.o `test -f 'src/pcre2test.c' || echo './'`src/pcre2test.c
> [...]
> src/pcre2test.c: In function 'process_pattern':
> src/pcre2test.c:5212:13: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'int' [-Wformat=]
>              "opening quote is at offset %" PTR_FORM ".\n", pq - buffer - 2);


I am going to need some help here. The PTR_FORM macro is set to the
appropriate print format for pointers. It is currently defined like
this:

/* VC and older compilers don't support %td or %zu, and even some that claim to
be C99 don't support it (hence DISABLE_PERCENT_ZT). */

#if defined(_MSC_VER) || !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L || defined(DISABLE_PERCENT_ZT)
#define PTR_FORM "lu"
#define SIZ_FORM "lu"
#define SIZ_CAST (unsigned long int)
#else
#define PTR_FORM "td"
#define SIZ_FORM "zu"
#define SIZ_CAST
#endif

I presume you are seeing %lu because gcc 4.8.5 triggers the
__STDC_VERSION__ test. What is the best way (compatible with 4.8.5) to
test for being in a 32-bit system at preprocessor time? Is

#if LONG_MAX == 2147483647

the right way to do it? If so, then PTR_FORM and SIZ_FORM can be defined
as "u" when that test is true. Presumably the cast is OK.

Philip

--
Philip Hazel