From 57fede7d6271d199ada81a0a0287f9587c3088b4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Aug 2023 19:27:44 +0100 Subject: [PATCH 01/15] Add some missing tests not being run --- Examples/test-suite/common.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index a8a179799eb..321e538f6a4 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -106,6 +106,7 @@ CPP_TEST_CASES += \ abstract_basecast \ abstract_inherit \ abstract_inherit_ok \ + abstract_inherit_using \ abstract_signature \ abstract_typedef \ abstract_typedef2 \ @@ -414,6 +415,7 @@ CPP_TEST_CASES += \ smart_pointer_protected \ smart_pointer_rename \ smart_pointer_simple \ + smart_pointer_static \ smart_pointer_template_const_overload \ smart_pointer_template_defaults_overload \ smart_pointer_templatemethods \ From bd2dcf920cb84c725dfb1f48718bdeb23976a3b5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Aug 2023 22:54:40 +0100 Subject: [PATCH 02/15] Correct attempts to not run tests in Javascript and Octave --- Examples/test-suite/javascript/Makefile.in | 3 ++- Examples/test-suite/octave/Makefile.in | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index 8167020d9ff..febff160701 100644 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -27,7 +27,8 @@ CPP_TEST_CASES += \ li_std_containers_int \ li_std_map_member -CPP_TEST_BROKEN += \ +# napi fails +FAILING_CPP_TESTS += \ smart_pointer_static \ SWIGEXE = $(top_builddir)/swig diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 5a092f5e37c..d3fa3c3ef89 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -27,12 +27,6 @@ CPP11_TEST_CASES += \ cpp11_shared_ptr_overload \ cpp11_shared_ptr_upcast \ -CPP_TEST_BROKEN += \ - implicittest \ - li_implicit \ - li_std_set \ - li_std_stream - include $(srcdir)/../common.mk # Overridden variables here From 8aab1590f228e0ee06972abe7e74753193e0642d Mon Sep 17 00:00:00 2001 From: Alexander Shadchin Date: Wed, 16 Aug 2023 20:10:34 +0300 Subject: [PATCH 03/15] Fix missing-field-initializers warning with Py3.12 --- Lib/python/builtin.swg | 6 ++++++ Lib/python/pyrun.swg | 9 +++++++++ Source/Modules/python.cxx | 3 +++ 3 files changed, 18 insertions(+) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 5cff6835f8e..d6b79bf725f 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -270,6 +270,9 @@ SwigPyStaticVar_Type(void) { #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif +#if PY_VERSION_HEX >= 0x030C0000 + 0, /* tp_watched */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ @@ -358,6 +361,9 @@ SwigPyObjectType(void) { #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif +#if PY_VERSION_HEX >= 0x030C0000 + 0, /* tp_watched */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 6b119be1c43..a86015cd659 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -388,6 +388,9 @@ swig_varlink_type(void) { #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif +#if PY_VERSION_HEX >= 0x030C0000 + 0, /* tp_watched */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ @@ -982,6 +985,9 @@ SwigPyObject_TypeOnce(void) { #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif +#if PY_VERSION_HEX >= 0x030C0000 + 0, /* tp_watched */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ @@ -1162,6 +1168,9 @@ SwigPyPacked_TypeOnce(void) { #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif +#if PY_VERSION_HEX >= 0x030C0000 + 0, /* tp_watched */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 22e6388406b..7e74df1d49e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4203,6 +4203,9 @@ class PYTHON:public Language { Printv(f, "#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)\n", NIL); printSlot(f, getSlot(), "tp_print"); Printv(f, "#endif\n", NIL); + Printv(f, "#if PY_VERSION_HEX >= 0x030C0000\n", NIL); + printSlot(f, getSlot(), "tp_watched"); + Printv(f, "#endif\n", NIL); Printv(f, "#ifdef COUNT_ALLOCS\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_allocs"), "tp_allocs", "Py_ssize_t"); From 8c6a0fb5cd97ee6dfc5684c04538c5d5add0cbb2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Aug 2023 21:53:16 +0100 Subject: [PATCH 04/15] Testcase fix for python-3.12 https://docs.python.org/3.12/whatsnew/3.12.html A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning --- Examples/test-suite/python/cpp11_raw_string_literals_runme.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py index 90e450f8b44..196bd4ec436 100644 --- a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py +++ b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py @@ -65,11 +65,11 @@ def check(got, expected): comment""") check(inspect.getdoc(RawStringDoc.YY), """Single line "raw string" documentation comment""") check(inspect.getdoc(RawStringDoc.ZZ), -"""Documentation comment +r"""Documentation comment as a "raw string" on multiple lines including a \ backslash""") -check(mm, """)I'm an "ascii" \ string constant with multiple +check(mm, r""")I'm an "ascii" \ string constant with multiple lines.""") From 1225b2e48482202383dd0af09005e48f4877b2ef Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Aug 2023 22:42:26 +0100 Subject: [PATCH 05/15] Fix testcase for python-3.12 Immortable Objects don't change reference counts, PEP 683 https://peps.python.org/pep-0683/ --- Examples/test-suite/python/langobj_runme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/langobj_runme.py b/Examples/test-suite/python/langobj_runme.py index b32d5a18a13..ce1c9cdf39a 100644 --- a/Examples/test-suite/python/langobj_runme.py +++ b/Examples/test-suite/python/langobj_runme.py @@ -2,7 +2,7 @@ from langobj import * -x = "hello" +x = 256*256+1 rx = sys.getrefcount(x) v = identity(x) rv = sys.getrefcount(v) From 3c5119c614808cf7413da0123766060fd0bd5432 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Aug 2023 00:27:17 +0100 Subject: [PATCH 06/15] Test python-3.12 on GHA, fix missing field initialization for builtin --- .github/workflows/ci.yml | 2 ++ CHANGES.current | 4 ++++ Lib/python/builtin.swg | 4 ++-- Source/Modules/python.cxx | 5 ++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78f1b33dda4..d514458e2d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -143,6 +143,8 @@ jobs: VER: '3.10' - SWIGLANG: python VER: '3.11' + - SWIGLANG: python + VER: '3.12' - SWIGLANG: python PY2: 2 SWIG_FEATURES: -builtin diff --git a/CHANGES.current b/CHANGES.current index 03341a9094a..9b629e4c559 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.2.0 (in progress) =========================== +2023-08-16: shadchin + [Python] #2665 Fix missing-field-initializers warning to provide support + for python-3.12. + 2023-08-09: olly [Ruby] Remove -feature command line option which has been deprecated since SWIG 1.3.32 in 2007. Use -init_name instead. diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index d6b79bf725f..d7593941533 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -270,7 +270,7 @@ SwigPyStaticVar_Type(void) { #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif -#if PY_VERSION_HEX >= 0x030C0000 +#if PY_VERSION_HEX >= 0x030c0000 0, /* tp_watched */ #endif #ifdef COUNT_ALLOCS @@ -361,7 +361,7 @@ SwigPyObjectType(void) { #if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) 0, /* tp_print */ #endif -#if PY_VERSION_HEX >= 0x030C0000 +#if PY_VERSION_HEX >= 0x030c0000 0, /* tp_watched */ #endif #ifdef COUNT_ALLOCS diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7e74df1d49e..0dc70742653 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4203,7 +4203,7 @@ class PYTHON:public Language { Printv(f, "#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)\n", NIL); printSlot(f, getSlot(), "tp_print"); Printv(f, "#endif\n", NIL); - Printv(f, "#if PY_VERSION_HEX >= 0x030C0000\n", NIL); + Printv(f, "#if PY_VERSION_HEX >= 0x030c0000\n", NIL); printSlot(f, getSlot(), "tp_watched"); Printv(f, "#endif\n", NIL); @@ -4350,6 +4350,9 @@ class PYTHON:public Language { // struct _specialization_cache _spec_cache; Printf(f, " {\n"); printSlot(f, getSlot(n, "feature:python:getitem"), "getitem", "PyObject *"); + Printv(f, "#if PY_VERSION_HEX >= 0x030c0000\n", NIL); + printSlot(f, getSlot(n, "feature:python:getitem_version"), "getitem_version", "uint32_t"); + Printv(f, "#endif\n", NIL); Printf(f, " }\n"); Printv(f, "#endif\n", NIL); Printf(f, "};\n\n"); From f64ce2cdb76a5a4ce0749320d2c5fcbd38b9ddc5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Aug 2023 01:11:33 +0100 Subject: [PATCH 07/15] Add in missing feature:python:tp_watched for python-3.12 --- Source/Modules/python.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 0dc70742653..83c5f6e725e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4204,7 +4204,7 @@ class PYTHON:public Language { printSlot(f, getSlot(), "tp_print"); Printv(f, "#endif\n", NIL); Printv(f, "#if PY_VERSION_HEX >= 0x030c0000\n", NIL); - printSlot(f, getSlot(), "tp_watched"); + printSlot(f, getSlot(n, "feature:python:tp_watched"), "tp_watched", "char"); Printv(f, "#endif\n", NIL); Printv(f, "#ifdef COUNT_ALLOCS\n", NIL); From ced86a53f90dbba7dfe9f9cca42eb417b06cc290 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Aug 2023 01:34:10 +0100 Subject: [PATCH 08/15] Fix python 3.12 tests python 3.12 headers are not C90 standards compliant --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d514458e2d9..86d443d507c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,6 +145,7 @@ jobs: VER: '3.11' - SWIGLANG: python VER: '3.12' + CSTD: gnu99 - SWIGLANG: python PY2: 2 SWIG_FEATURES: -builtin From fb511b2378f76ead5d9dad1cd0ffcbd5947d7d02 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Aug 2023 08:36:16 +0100 Subject: [PATCH 09/15] GHA: Add node 20, add gcc-13, test with clang-14 --- .github/workflows/ci.yml | 75 ++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86d443d507c..de9f7d1fa30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,8 +47,12 @@ jobs: - SWIGLANG: "" GCC: 12 os: ubuntu-22.04 + - SWIGLANG: "" + GCC: 13 + os: ubuntu-22.04 - SWIGLANG: "" compiler: clang + os: ubuntu-22.04 - SWIGLANG: csharp - SWIGLANG: d VER: 'ldc' @@ -75,6 +79,13 @@ jobs: - SWIGLANG: guile VER: '3.0' - SWIGLANG: java + - SWIGLANG: javascript + ENGINE: jsc + VER: '4.0' + - SWIGLANG: javascript + ENGINE: napi + VER: '18' + CPPSTD: c++11 #- SWIGLANG: javascript # ENGINE: node # VER: '6' @@ -94,21 +105,6 @@ jobs: ENGINE: node VER: '12' CPPSTD: c++11 - - SWIGLANG: javascript - ENGINE: node - VER: '18' - CPPSTD: c++14 - - SWIGLANG: javascript - ENGINE: napi - VER: '14' - CPPSTD: c++11 - - SWIGLANG: javascript - ENGINE: napi - VER: '18' - CPPSTD: c++14 - - SWIGLANG: javascript - ENGINE: jsc - VER: '4.0' - SWIGLANG: lua - SWIGLANG: lua VER: '5.3' @@ -266,66 +262,77 @@ jobs: CPPSTD: c++14 - SWIGLANG: tcl CPPSTD: c++14 - # c++17 testing (using gcc11) + # c++17 testing (using gcc13) - SWIGLANG: csharp CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: go VER: '1.17' CPPSTD: c++17 - GCC: 11 + GCC: 13 CSTD: gnu17 - SWIGLANG: guile CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: java CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: javascript ENGINE: node VER: '18' CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: lua CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: octave CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: perl5 CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: php CPPSTD: c++17 CSTD: gnu17 - GCC: 11 + GCC: 13 - SWIGLANG: python CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: r CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: ruby CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: scilab CPPSTD: c++17 - GCC: 11 + GCC: 13 - SWIGLANG: tcl CPPSTD: c++17 - GCC: 11 - # c++20 testing (using gcc12) - # ubuntu-22.04 is currently experimental on Github Actions, so limit to just one language for now + GCC: 13 + # c++20 testing (using gcc13) - SWIGLANG: python CPPSTD: c++20 - GCC: 12 + GCC: 13 + os: ubuntu-22.04 + - SWIGLANG: javascript + ENGINE: napi + VER: '20' + CPPSTD: c++20 + GCC: 13 + os: ubuntu-22.04 + - SWIGLANG: javascript + ENGINE: node + VER: '20' + CPPSTD: c++20 + GCC: 13 os: ubuntu-22.04 # Experimental languages (these are allowed to fail) - SWIGLANG: mzscheme continue-on-error: true #- SWIGLANG: ocaml # CPPSTD: c++17 - # GCC: 11 + # GCC: 13 # continue-on-error: true # os: ubuntu-18.04 # ocaml-4.08 in ubuntu-20.04 not yet working # Run all of them, as opposed to aborting when one fails From af7222f0f60c73f80cd10dbb17ee5f6bb29c6a6f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Aug 2023 22:51:08 +0100 Subject: [PATCH 10/15] CCache mdfour refactor to fix gcc-13 warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: mdfour.c:184:11: warning: storing the address of local variable ‘md’ in ‘m’ [-Wdangling-pointer=] --- CCache/mdfour.c | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/CCache/mdfour.c b/CCache/mdfour.c index 5b304852bcd..1d4060cdea5 100644 --- a/CCache/mdfour.c +++ b/CCache/mdfour.c @@ -24,8 +24,6 @@ It assumes that a int is at least 32 bits long */ -static struct mdfour *m; - #define MASK32 (0xffffffff) #define F(X,Y,Z) ((((X)&(Y)) | ((~(X))&(Z)))) @@ -38,12 +36,12 @@ static struct mdfour *m; #define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s) /* this applies md4 to 64 byte chunks */ -static void mdfour64(uint32 *M) +static void mdfour64(struct mdfour *md, uint32 *M) { uint32 AA, BB, CC, DD; uint32 A,B,C,D; - A = m->A; B = m->B; C = m->C; D = m->D; + A = md->A; B = md->B; C = md->C; D = md->D; AA = A; BB = B; CC = C; DD = D; ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7); @@ -80,7 +78,7 @@ static void mdfour64(uint32 *M) A &= MASK32; B &= MASK32; C &= MASK32; D &= MASK32; - m->A = A; m->B = B; m->C = C; m->D = D; + md->A = A; md->B = B; md->C = C; md->D = D; } static void copy64(uint32 *M, const unsigned char *in) @@ -111,15 +109,15 @@ void mdfour_begin(struct mdfour *md) } -static void mdfour_tail(const unsigned char *in, int n) +static void mdfour_tail(struct mdfour *md, const unsigned char *in, int n) { unsigned char buf[128]; uint32 M[16]; uint32 b; - m->totalN += n; + md->totalN += n; - b = m->totalN * 8; + b = md->totalN * 8; memset(buf, 0, 128); if (n) memcpy(buf, in, n); @@ -128,13 +126,13 @@ static void mdfour_tail(const unsigned char *in, int n) if (n <= 55) { copy4(buf+56, b); copy64(M, buf); - mdfour64(M); + mdfour64(md, M); } else { copy4(buf+120, b); copy64(M, buf); - mdfour64(M); + mdfour64(md, M); copy64(M, buf+64); - mdfour64(M); + mdfour64(md, M); } } @@ -142,10 +140,8 @@ void mdfour_update(struct mdfour *md, const unsigned char *in, int n) { uint32 M[16]; - m = md; - if (in == NULL) { - mdfour_tail(md->tail, md->tail_len); + mdfour_tail(md, md->tail, md->tail_len); return; } @@ -158,18 +154,18 @@ void mdfour_update(struct mdfour *md, const unsigned char *in, int n) in += len; if (md->tail_len == 64) { copy64(M, md->tail); - mdfour64(M); - m->totalN += 64; + mdfour64(md, M); + md->totalN += 64; md->tail_len = 0; } } while (n >= 64) { copy64(M, in); - mdfour64(M); + mdfour64(md, M); in += 64; n -= 64; - m->totalN += 64; + md->totalN += 64; } if (n) { @@ -181,12 +177,10 @@ void mdfour_update(struct mdfour *md, const unsigned char *in, int n) void mdfour_result(struct mdfour *md, unsigned char *out) { - m = md; - - copy4(out, m->A); - copy4(out+4, m->B); - copy4(out+8, m->C); - copy4(out+12, m->D); + copy4(out, md->A); + copy4(out+4, md->B); + copy4(out+8, md->C); + copy4(out+12, md->D); } @@ -272,7 +266,12 @@ static void file_checksum2(char *fname) printf("\n"); } #endif - +/* + * To test: + * gcc -DTEST_MDFOUR mdfour.c -o mdfourexe && ./mdfourexe + * then compare against a reference, such as: + * openssl dgst -md4 + */ int main(int argc, char *argv[]) { file_checksum1(argv[1]); From a7af35ecbc7e38c36e25f497bfddcd994aac9eb8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Aug 2023 23:05:08 +0100 Subject: [PATCH 11/15] Fix gcc-13 warning in scilab example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit error: ‘%d’ directive writing between 1 and 10 bytes into a region of size 3 [-Werror=format-overflow=] --- Examples/scilab/matrix2/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/scilab/matrix2/example.c b/Examples/scilab/matrix2/example.c index 232c8882431..02460348f21 100644 --- a/Examples/scilab/matrix2/example.c +++ b/Examples/scilab/matrix2/example.c @@ -132,7 +132,7 @@ void getStringVector(char ***resultVector, int *sizeRes) *resultVector = (char**) malloc((*sizeRes) * sizeof(char*)); for (i=0; i<*sizeRes; i++) { - char* pc = (char*) calloc(3, sizeof(char)); + char* pc = (char*) calloc(16, sizeof(char)); sprintf(pc, "%d", i); (*resultVector)[i] = pc; } From faf9c41666a68686af2757056654f8b3187c3406 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Aug 2023 23:13:52 +0100 Subject: [PATCH 12/15] Fix testcase warning with gcc-13 warning: moving a temporary object prevents copy elision [-Wpessimizing-move] --- Examples/test-suite/cpp11_ref_qualifiers.i | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/cpp11_ref_qualifiers.i b/Examples/test-suite/cpp11_ref_qualifiers.i index e37136770e5..23698f0d109 100644 --- a/Examples/test-suite/cpp11_ref_qualifiers.i +++ b/Examples/test-suite/cpp11_ref_qualifiers.i @@ -18,18 +18,18 @@ class Host { public: string h1() & { return string(); } string h2() const & { return string(); } - string h3() && { return std::move(string()); } - string h4() const && { return std::move(string()); } + string h3() && { return string(); } + string h4() const && { return string(); } string h5() const { return string(); } string h6() volatile const & { return string(); } string h7() const volatile & { return string(); } - string h8() volatile const && { return std::move(string()); } - string h9() const volatile && { return std::move(string()); } + string h8() volatile const && { return string(); } + string h9() const volatile && { return string(); } string h() & { return string(); } string h() const & { return string(); } - string h() && { return std::move(string()); } - string h() const && { return std::move(string()); } + string h() && { return string(); } + string h() const && { return string(); } }; %} @@ -89,11 +89,11 @@ struct Renames { %inline %{ struct ConversionOperators { virtual operator string() & { return string(); } - virtual operator string() && { return std::move(string()); } + virtual operator string() && { return string(); } virtual ~ConversionOperators() {} }; struct ConversionOperators2 { - virtual operator string() && { return std::move(string()); } + virtual operator string() && { return string(); } virtual ~ConversionOperators2() {} }; %} From 40099209bd986edb50060637729e1ad2e7792958 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Aug 2023 07:56:59 +0100 Subject: [PATCH 13/15] Remove incorrect fragment dependency --- Lib/swig.swg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/swig.swg b/Lib/swig.swg index 6dc2522d195..ce516368549 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -544,13 +544,13 @@ namespace std { /* memberin/globalin typemap for arrays. */ -%typemap(memberin,fragment="") SWIGTYPE [ANY] { +%typemap(memberin) SWIGTYPE [ANY] { size_t ii; $1_basetype *b = ($1_basetype *) $1; for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii); } -%typemap(globalin,fragment="") SWIGTYPE [ANY] { +%typemap(globalin) SWIGTYPE [ANY] { size_t ii; $1_basetype *b = ($1_basetype *) $1; for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii); @@ -558,7 +558,7 @@ namespace std { /* memberin/globalin typemap for double arrays. */ -%typemap(memberin,fragment="") SWIGTYPE [ANY][ANY] { +%typemap(memberin) SWIGTYPE [ANY][ANY] { $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); size_t ii = 0; @@ -570,7 +570,7 @@ namespace std { } } -%typemap(globalin,fragment="") SWIGTYPE [ANY][ANY] { +%typemap(globalin) SWIGTYPE [ANY][ANY] { $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); size_t ii = 0; From d60d94e8fe7b931dba730a00babb34ad300acdcf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Aug 2023 08:04:53 +0100 Subject: [PATCH 14/15] Fix for gcc-13 warning in SWIGTYPE[ANY][ANY] typemaps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../../typedef_array_member_wrap.cxx:1689:20: error: comparing the result of pointer addition ‘(arg2 + ((sizetype)(ii * 4)))’ and NULL [-Werror=address] 1689 | if (arg2[ii]) { --- Lib/typemaps/swigtype.swg | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg index 69f83794d23..ba8ce3c1f8f 100644 --- a/Lib/typemaps/swigtype.swg +++ b/Lib/typemaps/swigtype.swg @@ -172,12 +172,8 @@ if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) { - if ($input[ii]) { - size_t jj = 0; - for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; - } else { - %variable_nullref("$type","$name"); - } + size_t jj = 0; + for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } } else { %variable_nullref("$type","$name"); @@ -188,12 +184,8 @@ if ($input) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) { - if ($input[ii]) { - size_t jj = 0; - for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; - } else { - %variable_nullref("$type","$name"); - } + size_t jj = 0; + for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } } else { %variable_nullref("$type","$name"); @@ -208,12 +200,8 @@ } else if (inp) { size_t ii = 0; for (; ii < (size_t)$1_dim0; ++ii) { - if (inp[ii]) { - size_t jj = 0; - for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = inp[ii][jj]; - } else { - %variable_nullref("$type", "$name"); - } + size_t jj = 0; + for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = inp[ii][jj]; } } else { %variable_nullref("$type", "$name"); From 872a3ed77531a01e0e1369d52cbc3193f5917b8b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Aug 2023 08:22:57 +0100 Subject: [PATCH 15/15] Remove debug output from Octave test --- Examples/test-suite/octave/argcargvtest_runme.m | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/test-suite/octave/argcargvtest_runme.m b/Examples/test-suite/octave/argcargvtest_runme.m index 23687594f10..d1e4f3a6574 100644 --- a/Examples/test-suite/octave/argcargvtest_runme.m +++ b/Examples/test-suite/octave/argcargvtest_runme.m @@ -45,7 +45,6 @@ # Check that empty strings are handled. empty_string={"hello", blanks(0), "world"}; -disp(length(empty_string)); if (mainc(empty_string) != 3) error("bad main typemap"); endif