Fix build failure with GCC 14+ (C23 bool keyword and -Wint-conversion)#1385
Fix build failure with GCC 14+ (C23 bool keyword and -Wint-conversion)#1385messere1 wants to merge 1 commit into
Conversation
GCC 14 and 15 default to -std=gnu23, where 'bool' is a keyword. This causes two compile errors in IvorySQL-specific code: 1. src/interfaces/libpq/libpq-fe.h defines 'typedef unsigned char bool'. The existing guard '#if !(defined(true) && defined(false))' is not sufficient under C23, because true/false may not be defined as macros even though bool is a built-in keyword. Add a check for __STDC_VERSION__ >= 202311L (and __cplusplus) to skip the typedef, mirroring the pattern used in src/include/c.h. 2. contrib/ivorysql_ora/.../ora_xml_functions.c: ivy_xmlisvalid() returns Datum but the !USE_LIBXML fallback did 'return NULL'. With GCC 14's -Wint-conversion promoted to error, this fails. Replace with 'return 0' to match the upstream PostgreSQL xml.c pattern. Fixes IvorySQL#1351.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTwo independent build-compatibility fixes: the fallback return in ChangesC23 Build Compatibility Fixes
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This pull request fixes IvorySQL build failures with GCC 14+ (defaulting to -std=gnu23) by avoiding a C23/C++-conflicting bool typedef in libpq-fe.h and correcting a Datum-returning SQL function fallback that previously returned NULL (pointer) instead of an integer Datum.
Changes:
- Skip
typedef unsigned char bool;insrc/interfaces/libpq/libpq-fe.hwhen compiling as C++ or C23 (__STDC_VERSION__ >= 202311L), preventing GCC 14+ errors whereboolis a keyword. - Replace
return NULL;withreturn 0;in the!USE_LIBXMLfallback path ofivy_xmlisvalid()to avoid-Wint-conversionerrors and match existingNO_XML_SUPPORT(); return 0;conventions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/interfaces/libpq/libpq-fe.h | Extends the bool typedef guard to avoid redefining bool under C23 and C++. |
| contrib/ivorysql_ora/src/xml_functions/ora_xml_functions.c | Fixes ivy_xmlisvalid() fallback to return a valid Datum (0) after NO_XML_SUPPORT(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@hanjianqiao please follow up this pr. |
|
@messere1 Welcome to contribute to the IvorySQL community! The regression checks has started and we will review the code soon. |
Related Issue
Fixes #1351
Motivation
GCC 14 and 15 default to
-std=gnu23, wherebool,true, andfalseare C language keywords. This breaks the IvorySQL build in two places with IvorySQL-specific (non-upstream) code:Error 1 —
src/interfaces/libpq/libpq-fe.h:79:The existing guard
#if !(defined(true) && defined(false))is insufficient under C23:true/falsemay not be defined as macros even thoughboolis a built-in keyword, so the typedef is still emitted and fails.Error 2 —
contrib/ivorysql_ora/src/xml_functions/ora_xml_functions.c:2469:ivy_xmlisvalid()is declaredPG_FUNCTION_INFO_V1returningDatum, but its#else(no libxml) fallback didreturn NULL;. GCC 14 promotes-Wint-conversionto an error by default.Changes
src/interfaces/libpq/libpq-fe.h— Extend the guard so thetypedef unsigned char bool;is skipped under C23 (__STDC_VERSION__ >= 202311L) and C++ (__cplusplus), mirroring the pattern already used insrc/include/c.h:contrib/ivorysql_ora/src/xml_functions/ora_xml_functions.c— Inivy_xmlisvalid(), replacereturn NULL;withreturn 0;in the!USE_LIBXMLfallback, matching the upstream PostgreSQLsrc/backend/utils/adt/xml.cconvention for Datum-returning SQL functions.How Verified
c.hC23 guard;xml.creturn 0fallback).__STDC_VERSION__ < 202311L) the original typedef behavior is preserved exactly.Summary by CodeRabbit