Make SHM_ALL to a variable instead of a compound literal #define

gcc-9 has [improved compliance] with the C spec for lifetime of compound
literals, tying their lifetime to block scope instead of function scope.
This makes the behavior comparable to all other automatic variables.

Using the SHM_ALL #define instantiated a compound literal local to an if
clause and assigned the address to a "char_u *".  Since the pointer was
then being used outside of the if clause, it was using an invalid
address.

[improved compliance]: https://gcc.gnu.org/gcc-9/porting_to.html#complit

Closes #9855
This commit is contained in:
James McCoy 2019-04-07 19:50:54 -04:00 committed by Justin M. Keyes
parent 947069ba14
commit 1793ba8176
2 changed files with 9 additions and 8 deletions

View File

@ -306,6 +306,15 @@ static char *(p_cot_values[]) = { "menu", "menuone", "longest", "preview",
static char *(p_icm_values[]) = { "nosplit", "split", NULL };
static char *(p_scl_values[]) = { "yes", "no", "auto", NULL };
/// All possible flags for 'shm'.
static char_u SHM_ALL[] = {
SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI,
SHM_ABBREVIATIONS, SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER,
SHM_OVERALL, SHM_SEARCH, SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU,
SHM_RECORDING, SHM_FILEINFO,
0,
};
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "option.c.generated.h"
#endif

View File

@ -178,14 +178,6 @@ enum {
SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \
0, \
})
/// All possible flags for 'shm'.
#define SHM_ALL ((char_u[]) { \
SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \
SHM_ABBREVIATIONS, SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER, \
SHM_OVERALL, SHM_SEARCH, SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU, \
SHM_RECORDING, SHM_FILEINFO, \
0, \
})
/* characters for p_go: */
#define GO_ASEL 'a' /* autoselect */