GNU bug report logs -
#75964
Switching the Emacs build to -Wswitch-enum in src/
Previous Next
Full log
View this message in rfc822 format
On 2025-01-31 03:05, Pip Cet wrote:
> This GCC version is also patched to "infer" a switch type
Suppose the inference is wrong: how does one easily pacify the modified
GCC? Is it something like "case +PVEC_NORMAL:"?
Suppose one case has an enum type and another case has some other type:
is that an error?
> + case PVEC_FREE: eassume (0);
> + default: eassume (0);
Must this be written that way? Suppose I do this:
case PVEC_FREE:
default:
eassume (false);
Does that also pacify the modified GCC? Also, does emacs_abort () also
pacify the modified GCC?
Perhaps we should define a new macro eunreachable () that expands to
eassume (false). eunreachable : unreachable :: eassert : assert. This
might be a good idea regardless of anything else we do.
> alloc.c was a simple case because the enums are all internal
> to Emacs and unlikely to change drastically without people touching the
> code anyway. image.c is very different in that regard.
How does that sort of thing pan out?
> + ws="$ws -Wswitch-enum"
This won't work with the latest stable GCC, as it will cause false
positives. We need a way to have Emacs use -Wswitch-enum only with the
proposed patch installed. Perhaps the new GCC behavior should be enabled
by a new GCC option (not -Wswitch-enum), so that it's easy to test
whether the proposed GCC behavior is available.
> +ALL_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${LDFLAGS} ${CPPFLAGS} ${CFLAGS} ${PACIFYING_CFLAGS}
> CPP_CFLAGS = ${BASE_CFLAGS} ${PROFILING_CFLAGS} ${CPPFLAGS} ${CFLAGS}
> o
> ALL_CXXFLAGS = $(filter-out ${NON_CXX_CFLAGS},${BASE_CFLAGS}) \
> ${PROFILING_CFLAGS} ${LDFLAGS} ${CPPFLAGS} ${CFLAGS} ${CXXFLAGS} ${HAIKU_CFLAGS}
>
> +unfixed_Wswitch_obj += ctags${EXEEXT}
> +unfixed_Wswitch_obj += etags${EXEEXT}
This sort of thing can be confusing. Do we need it at all? That is, once
the fixes are in the C source files we shouldn't need to change the
Makefile.
Alternatively, perhaps it'd be better to use a pragma in the (I hope)
rare places we need to pacify GCC. E.g., how we currently treat
-Wanalyzer-null-dereference in four .c files.
This bug report was last modified 127 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.