Looking again at grep bug 39678 <https://bugs.gnu.org/39678> I noticed
that the bug occurs even when grep is not coloring:
echo a | grep -oi --color=never '\a'
This outputs nothing and exits with status 0, which is clearly wrong.
I tracked this down to a bug buried deep in the bowels of glibc regex, a
bug that Tomasz also spotted. It's not trivial to fix (the fix that
Tomasz sent in doesn't feel right, at least for \X where X is a
multibyte letter) and any fix would be low priority since the bug occurs
only in regular expressions like '\a' that have unspecified behavior -
which means the behavior though wrong nevertheless conforms to POSIX.
I'm inclined to address this by having GNU 'grep' diagnose unspecified
regexps like '\a' and exit with status 2, much as it already diagnoses
unspecified regexps like '[:alpha:]'. If this approach sounds too
drastic, a gentler approach would be for 'grep' to warn about '\a'
without changing the exit status for now, and escalate the warning to
exit with status 2 in a later 'grep' release.