Re: [PATCH] left shift of negative value do_binop src/arith_yacc.c:111:12
Steffen Nurpmeso <[email protected]> Fri, 01 Aug 2025 16:21:09 +0200
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <20250801142109.ljU470sn@steffen%sdaoden.eu> |
Harald van Dijk wrote in <[email protected]>: |On 31/07/2025 19:49, Aleksander Ushakov wrote: |> There is a fix of the problem: |> |> diff --git a/src/arith_yacc.c b/src/arith_yacc.c |> index 1a087c3..e23060d 100644 |> --- a/src/arith_yacc.c |> +++ b/src/arith_yacc.c |> @@ -108,7 +108,9 @@ static intmax_t do_binop(int op, intmax_t a, |> intmax_t b) |> case ARITH_SUB: |> return a - b; |> case ARITH_LSHIFT: |> - return a << b; |> + if (a < 0) |> + yyerror("left shift of negative value"); |> + return (intmax_t)a << b; |> case ARITH_RSHIFT: |> return a >> b; |> case ARITH_LT: |If other major shells already issued an error here, this change would |look fine (except again incomplete -- there is a lot more potential to |trigger sanitizer messages in this file), but as other major shells |accept this, I think dash should continue to accept this too. Well said. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) | |During summer's humble, here's David Leonard's grumble | |The black bear, The black bear, |blithely holds his own holds himself at leisure |beating it, up and down tossing over his ups and downs with pleasure | |Farewell, dear collar bear