This bug is very similar to another issue I reported, that was fixed in patch
7.4.1819.
clang -c -I. -Iproto -DHAVE_CONFIG_H -O2 -Wall -Wextra -fstack-protector
-fstack-protector-all -pedantic -pipe -mtune=native -fcolor-diagnostics
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -o objects/term.o term.c
term.c:2877:2: warning: embedding a directive within macro arguments has
undefined behavior [-Wembedded-directive]
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
^
1 warning generated.
The issue is caused because sprintf() is implemented as a macro on some
systems.
Therefore, this sprintf() call has its parameters conditionally modified by the
preprocessor, and embedding a preprocessor directive within macro arguments
causes undefined behavior.
>From src/term.c:
2875 sprintf(buf, format,
2876 i == 2 ?
2877 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
2878 s[1] == '|' ? IF_EB("\033|", ESC_STR "|") :
2879 #endif
2880 IF_EB("\033[", ESC_STR "[") : "\233",
2881 s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
2882 : (n >= 16 ? "48;5;" : "10"));
My proposed fix would be to move the preprocessor check outside the call to
sprintf().
2876 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
2877 sprintf(buf, format,
2878 i == 2 ?
2879 s[1] == '|' ? IF_EB("\033|", ESC_STR "|") :
2880 IF_EB("\033[", ESC_STR "[") : "\233",
2881 s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
2882 : (n >= 16 ? "48;5;" : "10"));
2883 #else
2884 sprintf(buf, format,
2885 i == 2 ?
2886 IF_EB("\033[", ESC_STR "[") : "\233",
2887 s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
2888 : (n >= 16 ? "48;5;" : "10"));
2889 #endif
I submitted a pull request: https://github.com/vim/vim/pull/2946
--
--
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].
For more options, visit https://groups.google.com/d/optout.