On 1/11/23 20:03, Carlo Arenas wrote: > Your suggested code doesn't address > that, it merely changes the error message with one that would be IMHO > even less clear and worsens the problem. In that case let's improve the error message wording; something like the attached patch, say. > Using a non Unicode PCRE library is perfectly fine, and there is no > "undefined behavior" risk, and indeed `grep -P` without the UTF flag > is exactly what the alternate path uses and what is recommended for > speed, so? It's not a question of undefined behavior. It's a question of whether grep does what the user requested. Without the attached patch, in a UTF-8 locale "grep -P '[[:alpha:]]'" won't report matching alphabetic characters, if they're multibyte. Silent misbehavior is quite bad, and it's better for grep to issue a diagnostic and exit than to silently do the wrong thing.