Fix invalid code in testcase typemap_qualifier_strip.i

This testcase was using a pointer to a variable which had gone out
of scope, which is undefined behaviour.  The test was only passing
because the tests are compiled without optimisation by default and
the memory where this value lived happened to remain intact in that
case with current versions of compilers we test with.  Running the
testsuite with CXXFLAGS=-O2 causes this test to fail.

Fix by extending the lifetime of the variable to the whole wrapper
function.

Fixes #1925
This commit is contained in:
Olly Betts 2022-01-26 15:39:38 +13:00
parent 4173892cca
commit 07f5b37c30
1 changed files with 6 additions and 6 deletions

View File

@ -4,18 +4,18 @@
%typemap(freearg) int *const ptrConst ""
%typemap(freearg) int const* constPtr ""
%typemap(in) int *ptr {
int temp = 1234;
%typemap(in) int *ptr (int temp) {
temp = 1234;
$1 = &temp;
}
%typemap(in) int *const ptrConst {
int temp = 5678;
%typemap(in) int *const ptrConst (int temp) {
temp = 5678;
$1 = &temp;
}
%typemap(in) int const* constPtr {
int temp = 3456;
%typemap(in) int const* constPtr (int temp) {
temp = 3456;
$1 = &temp;
}