mirror of https://github.com/swig/swig
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:
parent
4173892cca
commit
07f5b37c30
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue