Re: Fix accidentally cast away qualifiers - Mailing list pgsql-hackers
| From | Chao Li |
|---|---|
| Subject | Re: Fix accidentally cast away qualifiers |
| Date | |
| Msg-id | 5C33CCDF-7A95-4757-B35A-CA62C2D77F31@gmail.com Whole thread Raw |
| In response to | Re: Fix accidentally cast away qualifiers (Bertrand Drouvot <bertranddrouvot.pg@gmail.com>) |
| List | pgsql-hackers |
> On Jan 21, 2026, at 22:56, Bertrand Drouvot <bertranddrouvot.pg@gmail.com> wrote: > > Hi, > > On Wed, Jan 21, 2026 at 02:24:58PM +0000, Bertrand Drouvot wrote: >> Hi, >> >> On Wed, Jan 21, 2026 at 12:31:27PM +0100, Peter Eisentraut wrote: >>> Strange, I don't see that. What compiler is this, and do you use any >>> special options? >> >> It's gcc 14.1.0 with "CFLAGS=-O0 -ggdb3 -fno-omit-frame-pointer -gdwarf-2 -g3 >> -Wdiscarded-qualifiers -Wunused-value -Werror=maybe-uninitialized >> -Werror=format -Wreturn-type" >> >> But I just tested with a simple test case, some compilers and some options and I've >> always seen the warning (see [1]) > > FWIW, and so does the CI: https://github.com/bdrouvot/postgres/runs/61028037498 > > Regards, > > -- > Bertrand Drouvot > PostgreSQL Contributors Team > RDS Open Source Databases > Amazon Web Services: https://aws.amazon.com > Yeah, I confirm I can see the same warnings: ``` In file included from xlogdesc.c:21: In file included from ../../../src/include/utils/guc.h:17: In file included from ../../../src/include/utils/array.h:65: In file included from ../../../src/include/utils/expandeddatum.h:47: ../../../src/include/varatt.h:307:9: warning: returning 'const char[]' from a function with result type 'char *' discardsqualifiers [-Wincompatible-pointer-types-discards-qualifiers] 307 | return VARDATA_4B(PTR); | ^~~~~~~~~~~~~~~ ../../../src/include/varatt.h:261:26: note: expanded from macro 'VARDATA_4B' 261 | #define VARDATA_4B(PTR) (((const varattrib_4b *) (PTR))->va_4byte.va_data) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../src/include/varatt.h:321:9: warning: returning 'const char[]' from a function with result type 'char *' discardsqualifiers [-Wincompatible-pointer-types-discards-qualifiers] 321 | return VARDATA_1B(PTR); | ^~~~~~~~~~~~~~~ ../../../src/include/varatt.h:263:26: note: expanded from macro 'VARDATA_1B' 263 | #define VARDATA_1B(PTR) (((const varattrib_1b *) (PTR))->va_data) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../src/include/varatt.h:342:9: warning: returning 'const char[]' from a function with result type 'char *' discardsqualifiers [-Wincompatible-pointer-types-discards-qualifiers] 342 | return VARDATA_1B_E(PTR); | ^~~~~~~~~~~~~~~~~ ../../../src/include/varatt.h:264:27: note: expanded from macro 'VARDATA_1B_E' 264 | #define VARDATA_1B_E(PTR) (((const varattrib_1b_e *) (PTR))->va_data) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../src/include/varatt.h:488:9: warning: returning 'const char *' from a function with result type 'char *' discardsqualifiers [-Wincompatible-pointer-types-discards-qualifiers] 488 | return VARATT_IS_1B(PTR) ? VARDATA_1B(PTR) : VARDATA_4B(PTR); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../src/include/varatt.h:235:2: note: expanded from macro 'VARATT_IS_1B' 235 | ((((const varattrib_1b *) (PTR))->va_header & 0x01) == 0x01) | ^ 4 warnings generated. ``` I didn’t use any special compiler option, just ran “make”. My configure is: ``` ./configure --enable-debug --enable-cassert --enable-tap-tests --enable-depend ``` Sorry, I didn’t notice the warnings in my first review. I guess I left my desktop while building at the time. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/
pgsql-hackers by date: