| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Fix accidentally cast away qualifiers |
| Date: | 2026-01-22 08:22:24 |
| Message-ID: | 5C33CCDF-7A95-4757-B35A-CA62C2D77F31@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Jan 21, 2026, at 22:56, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)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 *' discards qualifiers [-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 *' discards qualifiers [-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 *' discards qualifiers [-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 *' discards qualifiers [-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/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Pavel Stehule | 2026-01-22 08:26:28 | proposal: parentid and naturalid for plpgsql nodes |
| Previous Message | Michael Paquier | 2026-01-22 08:16:11 | Re: Add WALRCV_CONNECTING state to walreceiver |