tests: Unregister a destructor on leaving a test function
GCC 12 started to warn on a global variable pointing to a local variable
after getting out of scope of the local variable:
gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src -I../../src -DSRCDIR=\"../..\" -I/usr/include/libxml2 -DLOCALEDIR=\"/usr/share/locale\" -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Werror -std=c99 -Wall -c -o isds_PersonName_duplicate.o isds_PersonName_duplicate.c
In file included from isds_PersonName_duplicate.c:1:
isds_PersonName_duplicate.c: In function ‘test_isds_PersonName_duplicate’:
../test.h:39:30: error: storing the address of local variable ‘copy’ in ‘test_destructor_argument’ [-Werror=dangling-pointer=]
39 | test_destructor_argument = argument; \
isds_PersonName_duplicate.c:6:29: note: ‘copy’ declared here
6 | struct isds_PersonName *copy = isds_PersonName_duplicate(origin);
| ^~~~
../test.h:21:14: note: ‘test_destructor_argument’ declared here
21 | extern void *test_destructor_argument;
| ^~~~~~~~~~~~~~~~~~~~~~~~