Re: patch: Use pg_assume in jsonb_util.c to fix GCC 15 warnings
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Dmitry Mityugov <d.mityugov@postgrespro.ru>, pgsql-hackers@postgresql.org
Date: 2025-07-12T19:23:26Z
Lists: pgsql-hackers
Attachments
- v3-rationalize-compareJsonbContainers.patch (text/x-diff) patch v3
After further study I've understood what was bothering me about the logic in compareJsonbContainers (lines 280ff). Because JsonbIteratorNext doesn't presently guarantee to set val->type when returning WJB_DONE, the stanza appears to be at risk of undefined behavior should one iterator return that while the other returns something else. The comment fails to discuss this case, and the code doesn't consider it either. But in reality, the case cannot happen for the exact same reason that WJB_END_ARRAY and WJB_END_OBJECT can't occur: our earlier tests of object and array structure & length matching guarantee that we can't reach the end of one input before the other. So I think we need to rewrite that comment and extend the assertions, along the lines of the separate patch attached. This gets through check-world, which is unsurprising because if it did not we'd have seen use-of-undefined-value Valgrind complaints long since. I still think that we should silence the compiler warnings by removing the undefined-ness per my previous patch. I'm inclined to back-patch that (for people compiling old branches with latest compiler) but apply this bit to HEAD only (since it's just a code clarification). regards, tom lane
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Clarify the ra != rb case in compareJsonbContainers().
- 2a3a3964328a 19 (unreleased) landed
-
Silence uninitialized-value warnings in compareJsonbContainers().
- f32e45641460 15.14 landed
- aad1617b76ae 19 (unreleased) landed
- 8254b7e33be9 14.19 landed
- 6c93bf735ce1 13.22 landed
- 5db55e13f210 16.10 landed
- 5a2139a90690 17.6 landed
- 0b6dfce0ce4d 18.0 landed