On 28-Apr-2020 07:00, John Marriott wrote:

On 28-Apr-2020 06:48, Bram Moolenaar wrote:
Patch 8.2.0650
Problem:    Vim9: script function can be deleted.
Solution:   Disallow deleting script function.  Delete functions when sourcing
             a script again.
Files:      src/userfunc.c, src/proto/userfunc.pro, src/evalfunc.c,
             src/vim9compile.c, src/vim9execute.c, src/vim9script.c,
             src/scriptfile.c, src/testing.c, src/testdir/test_vim9_expr.vim,              src/testdir/test_vim9_func.vim, src/testdir/test_vim9_script.vim


After this patch, mingw64 (gcc 9.3.1) spits out this warning:
gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return userfunc.c -o gobjnative/userfunc.o
In file included from userfunc.c:14:
userfunc.c: In function 'delete_script_functions':
vim.h:1594:45: warning: 'fp' may be used uninitialized in this function [-Wmaybe-uninitialized]  1594 | #define STRNCMP(d, s, n)    strncmp((char *)(d), (char *)(s), (size_t)(n))
      |                                             ^
userfunc.c:1587:14: note: 'fp' was declared here
 1587 |     ufunc_T *fp;
      |              ^~

Cheers
John

This patch tries to fix it.

Cheers
John

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/451561d5-5b8b-9d77-319f-6b34fc759127%40internode.on.net.
--- userfunc.c.orig     2020-04-28 06:55:08.666776700 +1000
+++ userfunc.c  2020-04-28 07:16:42.783805700 +1000
@@ -1599,9 +1599,9 @@
     for (hi = func_hashtab.ht_array; todo > 0; ++hi)
        if (!HASHITEM_EMPTY(hi))
        {
+           fp = HI2UF(hi);
            if (STRNCMP(fp->uf_name, buf, len) == 0)
            {
-               fp = HI2UF(hi);
                fp->uf_flags |= FC_DEAD;
                func_clear(fp, TRUE);
            }

Raspunde prin e-mail lui