Skip to content

Commit 4b2a254

Browse files
committed
Add a note to PG_TRY's documentation about volatile safety.
We had better memorialize what the actual requirements are for this.
1 parent dabda64 commit 4b2a254

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/include/utils/elog.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,13 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
332332
* not without taking thought for what will happen during ereport(FATAL).
333333
* The PG_ENSURE_ERROR_CLEANUP macros provided by storage/ipc.h may be
334334
* helpful in such cases.
335+
*
336+
* Note: if a local variable of the function containing PG_TRY is modified
337+
* in the PG_TRY section and used in the PG_CATCH section, that variable
338+
* must be declared "volatile" for POSIX compliance. This is not mere
339+
* pedantry; we have seen bugs from compilers improperly optimizing code
340+
* away when such a variable was not marked. Beware that gcc's -Wclobbered
341+
* warnings are just about entirely useless for catching such oversights.
335342
*----------
336343
*/
337344
#define PG_TRY() \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy