[gdal-dev] port/cpl_json.h and clang -Wsign-conversion

Andrew C Aitchison gdal at aitchison.me.uk
Tue Jan 27 04:32:18 PST 2026


The recent commit 76ade06580d5f6b4f710d41214647abf36be9fdc
includes this change:

@@ -279,6 +299,13 @@ class CPL_DLL CPLJSONArray : public CPLJSONObject
      /*! @endcond */
    public:
      int Size() const;
+
+    //! Return the size of the array
+    inline size_t size() const
+    {
+        return Size();
+    }
+
      void AddNull();
      void Add(const CPLJSONObject &oValue);
      void Add(const std::string &osValue);

I usually build my driver with clang++ -Werror -Wsign-conversion
but this compile is catching the change:

clang++-22 -fPIC -I/usr/local/gdal/git.llvm/include -Weffc++ -g -Og -Wall 
-Wextra -DFRMT_vrc -DVRC_STANDALONE
-Wno-unknown-pragmas -Wall -Wextra -Werror -Wno-unknown-pragmas 
-Weverything -Wno-c++17-attribute-extensions
-Wno-error=unknown-warning-option -Wno-format-pedantic -Wno-c++98-compat 
-Wno-c++98-compat-pedantic -Wno-padded
-Wno-reserved-identifier -Werror=incompatible-function-pointer-types 
-Wno-unsafe-buffer-usage -Wno-error=unknown-warning-option
-c -o VRC.o VRC.cpp
In file included from VRC.cpp:37:
In file included from ./VRC.h:61:
In file included from /usr/local/gdal/git.llvm/include/gdal_pam.h:22:
In file included from /usr/local/gdal/git.llvm/include/gdal_priv.h:46:
In file included from /usr/local/gdal/git.llvm/include/ogr_feature.h:20:
In file included from /usr/local/gdal/git.llvm/include/ogr_geometry.h:19:
/usr/local/gdal/git.llvm/include/cpl_json.h:306:16: error: implicit 
conversion changes
       signedness: 'int' to 'size_t' (aka 'unsigned long') 
[-Werror,-Wsign-conversion]
   306 |         return Size();
       |         ~~~~~~ ^~~~~~

Am I wrong to be using -Wsign-conversion even though it has worked
until now ?

Thanks,

-- 
Andrew C. Aitchison                      Kendal, UK
                    andrew at aitchison.me.uk


More information about the gdal-dev mailing list